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
medium

Method Overriding and Super Keyword

< Prev
Next >

Consider the following class declarations.

class Alpha {
    int a = 2;
    int multiply() { return a * 3; }
}

class Beta extends Alpha {
    int a = 4;
    int multiply() { return super.multiply() + a; }
    public static void main(String[] args) {
        System.out.println(new Beta().multiply());
    }
}

What is printed when the program is executed?

A

6

B

8

C

Compilation Error

D

10

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

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: apfive@apfive.org|Privacy Policy|