public class A {
public int doubleIt(int n) { return n * 2; }
}
public class B extends A { }
System.out.println(new B().doubleIt(7));What is printed?
- A
Compile-time error
- B
7
- Ccheck_circle
14
- D
0
Explanation
B inherits doubleIt from A.
AP Computer Science A· difficulty 2/5
public class A {
public int doubleIt(int n) { return n * 2; }
}
public class B extends A { }
System.out.println(new B().doubleIt(7));What is printed?
Compile-time error
7
14
0
Explanation
B inherits doubleIt from A.
Want 10 more like this — adaptive to your weak spots?