| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice Test
Share
medium Solved by 5 students
Method Overriding and Superclass Calls
< Prev
Next >

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

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki12 0m 00s 90
#2psak1211 2m 12s -32
#3y.seong202702 1m 12s -92
#4suhanakochhar00614 11m 29s -619
APFIVE © 2020.
Email: [email protected]|Privacy Policy