Recall & Review
beginner
What is an instance method in Java?
An instance method is a method that belongs to an object of a class. It can access instance variables and requires an object to be called.
Click to reveal answer
beginner
How do you call an instance method in Java?
You call an instance method by using an object of the class followed by a dot and the method name, like <code>objectName.methodName()</code>.Click to reveal answer
intermediate
Can an instance method access static variables directly?
Yes, an instance method can access static variables directly because static variables belong to the class, not to any specific object.
Click to reveal answer
intermediate
What is the difference between an instance method and a static method?
An instance method requires an object to be called and can access instance variables. A static method belongs to the class itself and can be called without creating an object.Click to reveal answer
intermediate
Why can't you call an instance method from a static context without an object?
Because instance methods need an object to know which instance's data to work with. Static context has no specific object, so it cannot call instance methods directly.
Click to reveal answer
How do you call an instance method named
display on an object car?✗ Incorrect
You call an instance method using the object name followed by a dot and the method name:
car.display().Which of these is true about instance methods?
✗ Incorrect
Instance methods belong to objects and can access instance variables. They require an object to be called.
Can an instance method access static variables?
✗ Incorrect
Instance methods can access static variables because static variables belong to the class.
What happens if you try to call an instance method from a static method without an object?
✗ Incorrect
You get a compile-time error because instance methods need an object to be called.
Which keyword is used to refer to the current object inside an instance method?
✗ Incorrect
The keyword
this refers to the current object inside an instance method.Explain what an instance method is and how it differs from a static method.
Think about whether you need an object to call the method.
You got /4 concepts.
Describe why you cannot call an instance method directly from a static method without an object.
Consider what 'static' means about belonging to the class.
You got /3 concepts.