Method Overriding and Superclass Calls
Consider the following class declarations.
public class Thing1
{
public void calc(int n)
{
n *= 3;
System.out.print(n);
}
}
public class Thing2 extends Thing1
{
public void calc(int n)
{
n += 2;
super.calc(n);
System.out.print(n);
}
}
The following code segment is executed in a method of a class other than Thing1 or Thing2.
Thing1 t = new Thing2();
t.calc(2);
What is printed when the code segment is executed?
A
124
B
68
C
1212
D
6
Question Leaderboard
| Rank | |||||
|---|---|---|---|---|---|
| #1 | kaisuki | 1 | 2 | 0m 00s | 90 |
| #2 | psak12 | 1 | 1 | 2m 12s | -32 |
| #3 | y.seong2027 | 0 | 2 | 1m 12s | -92 |
| #4 | suhanakochhar006 | 1 | 4 | 11m 29s | -619 |
Items per page:
10
1 – 4 of 4
APFIVE