Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
medium Solved by 3 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

6

B

124

C

68

D

1212

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total 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|FAQ