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

List types of storage classes in java?

826


Why vector is used in java?

767


What is charat ()?

722


What is argument in java?

764


What do you know about java?

722


What is the java reflection api? Why it’s so important to have?

753


Which is faster call by value or call by reference?

706


What is a Null object?

1200


How do you differentiate abstract class from interface?

734


What is the concatenation operator in java?

818


Can you override a final method?

787


Can we declare the main method of our class as private?

764


Difference between predicate, supplier and consumer ?

807


What is java util hashmap?

729


Why java is used everywhere?

760