Method Overriding and Superclass Calls
Consider the following class definitions.
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 appears in a class other than Thing1 or Thing2.
Thing1 t = new Thing2();
t.calc(2);
What is printed as a result of executing the code segment?
A
6
B
124
C
68
D
1212
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 |
APFIVE