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

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

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

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
Items per page:
10
1 – 4 of 4
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy