Search the courses, subjects, tracks, games and features, or jump straight to a page.
3 cards from this section. Quick, good the night before a test.
What is a local variable?
Think about where a variable can be accessed.
What is an instance variable?
Consider how objects relate to instances.
What type of variable is declared inside a method?
Think about the scope of variables.
True or False: Instance variables are shared among all instances of a class.
Think about how objects work.
Create a Student class with an instance variable name and a static variable numberOfStudents. Write methods to set the name, and to return both the name and the total number of students.
Remember to increment the static variable when a new student is added.
In a game application, if each player has an instance variable score but a static variable highScore, what would happen if we only used a static variable for score?
Consider the uniqueness required for each player.
5 more questions in this section. Enroll free to practise them all.
Enroll free