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

What is output buffer?

799


Are arrays static in java?

806


What is the purpose of tostring() method in java?

812


Can you override private or static method in java?

765


When does an object becomes eligible for garbage collection in java?

824


What is mvc in java?

803


What is final, finally, finalize?

810


What is string and its types?

860


What is early binding and late binding in java?

817


Can we overload final method in java?

749


What is the difference between a synchronized method and a synchronized block?

878


What is variable and its types?

775


What are the high-level thread states in java programming?

847


What do negative exponents mean?

763


What is the longest unicode character?

907