Recall & Review
beginner
What does the static keyword mean in Java?
The <strong>static</strong> keyword means the member belongs to the class itself, not to any specific object. It can be accessed without creating an object.touch_appClick to reveal answer
beginner
How do non-static members behave differently from static members?
Non-static members belong to individual objects. Each object has its own copy, so changes affect only that object.
touch_appClick to reveal answer
intermediate
Can a static method access non-static variables directly? Why or why not?
No, a static method cannot access non-static variables directly because non-static variables belong to objects, and static methods belong to the class without any object context.touch_appClick to reveal answer
intermediate
What happens if you try to use
this keyword inside a static method?You cannot use
this inside a static method because this refers to the current object, and static methods do not belong to any object.touch_appClick to reveal answer
beginner
Give a real-life example to explain static vs non-static behavior.
Think of a school: The school name is static because it is the same for all students (objects). Each student has their own name and grades, which are non-static because they differ per student.
touch_appClick to reveal answer
Which of the following is true about static variables in Java?
Can a non-static method access static variables directly?
What will happen if you try to access a non-static variable inside a static method without an object?
Which keyword is used to declare a static method in Java?
If you want a variable to be unique for each object, how should you declare it?
Explain the difference between static and non-static members in Java with examples.
Describe why static methods cannot use the 'this' keyword and what that means for accessing variables.
