Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+13 votes

What is the difference between static and instance variables and methods?

asked in CSC305 Fall 2022 by (1 point)

1 Answer

+7 votes

static method: methods that can be called without creating an object
instance method: requires an object of its class to be created before it can be used

static var: belongs to class; all object will share single copy that belongs to the class
instance var: belongs to object; each object will have its own copy of variable

answered by (1 point)
...