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

Why singleton pattern is better than creating singleton class with static instance?

639


Difference between throw and throws?

733


Why do we need data serialization?

631


what do you mean by marker interface in java?

656


Write code of any action class?

633






What are synchronized methods ?

709


What do you know about the garbage collector?

694


What is return in java?

634


What is autoboxing in java?

700


What is the purpose of main function in java?

632


Is zero a natural number?

663


Is array serializable java?

606


What is externalizable interface?

691


What is n in java?

620


What is an interface in java? Explain

680