what is the difference between static and instance variable?
Answers
Answered by
1
Answer:
Instance variables are created when an object is created with the use of the keyword 'new' and destroyed when the object is destroyed. Static variables are created when the program starts and destroyed when the program stops. Instance variables can be accessed directly by calling the variable name inside the class.
Explanation:
Hope this will help u.......
Have a great day
plz mark me brainliest
Answered by
4
Question:-
What is the difference between static and instance variables?
Answer:-
The main differences are as follows:-
- Static variables are declared with keyword static whereas Instance variables are declared without static keyword.
- Static variables are common to all instances of a class whereas instance variables are not shared between the objects of a class.
- Static variables can be accessed using either class name or object reference whereas instance variables can be accessed only through object reference.
Similar questions