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

How does indexof work?

507


Why we use methods in java?

544


What is anagram of a string?

523


What is boolean query?

536


What are encapsulation, inheritance and polymorphism?

531






What are the two ways of implementing multi-threading in java?

820


Define nashorn in java8.

570


how to split string in java?

660


How big is a gigabyte?

622


What are wrapper classes in java?

601


Tell me the latest versions in java related areas?

587


What is console based application in java?

548


What is object data type?

571


What is struts in java?

581


How do you reverse a list?

558