Search the courses, subjects, tracks, games and features, or jump straight to a page.
4 cards from this section. Quick, good the night before a test.
What is an instance method?
Think of instance methods as functions related to specific objects.
Can instance methods access static variables?
Recall the difference between instance and static variables.
What is the main requirement for invoking an instance method?
Consider what links the method to a specific object.
Instance methods can access which type of variables?
Remember the difference between instance and static variables.
Write a Java class called BankAccount that has instance methods to deposit, withdraw, and check the current balance. Demonstrate how these methods interact with account data.
Make sure to initialize the balance and demonstrate each method's effect.
Create a class called Person that has instance methods to set and get the person's name and age. Show how these methods manipulate instance variables.
Remember to account for encapsulation principles in your design.
7 more questions in this section. Enroll free to practise them all.
Enroll free