- A Local variables have scope within the block where they are declared.
- B Instance variables have scope within the class where they are defined.
- C Class variables (static variables) have scope within the class and its subclasses.
- D All of the above.
- Share this MCQ
Answer:
D
Share this MCQ
Variables in Java have scope depending on the type of variable. Local variables have scope within the block where they are declared, instance variables have scope within the class where they are defined, and class variables (static variables) have scope within the class and its subclasses. All of the above scenarios are correct.
Click me to Read more Question & Answer of Java Interviews MCQsShare this MCQ