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

Answer Posted / sathya

Static variables:
There is only one copy of static variable and even
when the class is instatiated, the value remains the same.

Non-static variables:
Every time the class is instatiated, the objest has
their own copy of these variables.

Is This Answer Correct ?    72 Yes 13 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What invokes a thread's run() method in java programming?

568


What are variable names?

527


How do you convert an int to a string in java?

544


What does this () mean in constructor chaining concept?

560


What is outofmemoryerror in java?

566






is there a separate stack for each thread in java? : Java thread

538


Can you run java program without main method?

543


Can we have try without catch block?

642


What is consumer in java?

522


design an lru cache in java?

543


What if static is removed from main method?

570


What does 3 dots mean in java?

519


What are the states of thread in java?

513


What is a control variable example?

529


What is tcp and udp?

602