Recall & Review
beginner
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.touch_appClick to reveal answer
beginner
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.
touch_appClick to reveal answer
beginner
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.
touch_appClick to reveal answer
intermediate
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.
touch_appClick to reveal answer
beginner
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.
touch_appClick to reveal answer
What does the static keyword do in Java?
Which of these can be called without creating an object?
Static variables are shared by:
Can a static method access instance variables directly?
Why might you make a method static?
Explain why static variables are useful in Java.
Describe a situation where you would use a static method instead of an instance method.
