Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
hard

Method Overriding And Increment Operators

Mark
< Prev
Next >

What is printed when the following program is executed?

class Number {
    int x = 10;
    int update() { return x++; }
}

class SubNumber extends Number {
    int update() { return ++x + super.update(); }
    public static void main(String[] args) {
        SubNumber sn = new SubNumber();
        System.out.println(sn.update());
    }
}
A

22

B

20

C

Compilation Error

D

21

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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