| 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
< Prev
Next >

What does the program print when 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

21

B

20

C

Compilation Error

D

22

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy