What is the difference between static and non-static
variables?

Answer Posted / sandhya reddy

Static Variables are loading when class is loading to the JVM.

Non-Static Variables are loading only when an object is
creating for the particular class.Non- Static variables
can't use inside Static Methods untill and unless creating
an object of that class.with the object reference only we
can asle to use Non-static variables inside Static methods,
But inside Non-Static methods we able to use static
variables without creating any object.

Is This Answer Correct ?    11 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we make constructors static?

761


What is a programming object?

589


How to sort double array in java?

619


How many boolean functions are there?

541


Name and explain the types of ways which are used to pass arguments in any function in java.

610






What are parsers? Dom vs sax parser.

589


How can we create a thread in java?

616


How do you remove spaces in java?

579


How is a variable stored in memory?

572


Explain java heap space and garbage collection?

620


Why java is secure? Explain.

631


What are local variables?

630


What is a nested class?

626


What is jrmp?

581


What is sorting in java?

574