Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 1 students

Inheritance and Static Variables

< Prev
Next >

Consider the following class declarations.

public class Parent {
   public static int value = 10;
}

public class Child extends Parent {
   public static int value = 20;
   public void printValues() {
       System.out.println("Child: " + value);
       System.out.println("Parent: " + super.value);
   }
}

public class Main {
   public static void main(String[] args) {
       new Child().printValues();
   }
}

What is printed when the main method of the Main class is executed?

A

Child: 10
Parent: 20

B

Child: 10
Parent: 10

C

Child: 20
Parent: 10

D

Child: 20
Parent: 20

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question
Mark for review

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|FAQ