Bird
0
0

Which of the following is the correct syntax to access a parent class variable named count from a subclass?

easy📝 Syntax Q3 of 15
Java - Inheritance
Which of the following is the correct syntax to access a parent class variable named count from a subclass?
Aparent.count;
Bthis.super.count;
Csuper->count;
Dsuper.count;
Step-by-Step Solution
Solution:
  1. Step 1: Recall syntax for accessing parent variables

    Use super.variableName to access parent class variables.
  2. Step 2: Eliminate invalid syntax

    this.super and super-> are invalid in Java; parent is not a keyword.
  3. Final Answer:

    super.count; -> Option D
  4. Quick Check:

    Access parent variable = super.variable [OK]
Quick Trick: Use super.variableName to access parent variables [OK]
Common Mistakes:
  • Using this.super which is invalid
  • Using arrow operator like in C++
  • Assuming parent is a keyword

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Java Quizzes