Bird
0
0

What is true about instance variables in Java?

easy📝 Conceptual Q1 of 15
Java - Classes and Objects
What is true about instance variables in Java?
AThey belong to an object and each object has its own copy.
BThey are shared by all objects of a class.
CThey must be declared inside a method.
DThey cannot have access modifiers.
Step-by-Step Solution
Solution:
  1. Step 1: Understand instance variable ownership

    Instance variables belong to objects, so each object has its own copy.
  2. Step 2: Compare with other variable types

    Static variables are shared by all objects, but instance variables are not.
  3. Final Answer:

    They belong to an object and each object has its own copy. -> Option A
  4. Quick Check:

    Instance variables = belong to object [OK]
Quick Trick: Instance variables belong to objects, not the class itself. [OK]
Common Mistakes:
  • Confusing instance variables with static variables.
  • Thinking instance variables are declared inside methods.
  • Assuming instance variables cannot have access modifiers.

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes