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 the scope of a variable declared within a method?
Think about where the variable can be accessed.
What is the difference between an instance variable and a class variable?
Consider their declaration location in a class.
What type of scope does a variable have if it is declared inside a method?
Think about how accessibility differs in methods.
True or False: An instance variable can only be accessed by the class in which it is declared.
Consider the accessibility across methods.
Design a class named Vehicle with an instance variable for the model and a class variable for the number of wheels. Write methods to set and display these appropriately.
Consider how you would create instances of this vehicle and access both variables.
Explain the implications of variable scope on memory management. How do local, instance, and class variables differ in terms of memory allocation?
Think about when each variable type is created and destroyed.
7 more questions in this section. Enroll free to practise them all.
Enroll free