| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
Share
About Exam
medium Solved by 2 students
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

10

C

Compilation Error

D

8

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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