Recall & Review
beginner Click to reveal answer
What does the static keyword mean in Java?
It means the member (variable or method) belongs to the class itself, not to any specific object of the class.beginner Click to reveal answer
Why do we use static methods in Java?
Because static methods can be called without creating an object, making them useful for utility or helper functions.
beginner Click to reveal answer
How does a static variable differ from an instance variable?
A static variable is shared by all objects of the class, while an instance variable is unique to each object.
intermediate Click to reveal answer
Can a static method access instance variables directly? Why or why not?
No, because static methods belong to the class, and instance variables belong to objects. Without an object, instance variables don't exist.
beginner Click to reveal answer
Give a real-life example of when static is useful.
Think of a calculator app: the add method can be static because it doesn’t need to remember any data, it just adds numbers given to it.
What does the static keyword do in Java?
✗ Incorrect
Static means the member belongs to the class, not to any object.
Which of these can be called without creating an object?
✗ Incorrect
Static methods belong to the class and can be called directly.
Static variables are shared by:
✗ Incorrect
Static variables are common to all objects of the class.
Can a static method access instance variables directly?
✗ Incorrect
Static methods don’t have access to instance variables without an object.
Why might you make a method static?
✗ Incorrect
Static methods can be called directly on the class without objects.
Explain why static variables are useful in Java.
Think about data that should be the same for every object.
You got /4 concepts.
Describe a situation where you would use a static method instead of an instance method.
When the method doesn’t rely on object-specific information.
You got /4 concepts.
