Question OOP-INH-0019
HardWhat is the output of this code?
class Parent { int x = 10; }
class Child extends Parent { int x = 20; }
public class Main {
public static void main(String[] args) {
Parent p = new Child();
System.out.println(p.x);
}
}
- A.
Error
- B.
0
- C.
Sign up free to see the answer and a step-by-step explanation.