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
easy Solved by 2 students

Method Overriding with Super Keyword

Mark
< Prev
Next >

What is printed when the following program is executed?

class Greeting {
    String sayHello() { return "Hello"; }
}

class PersonalizedGreeting extends Greeting {
    String name = "Alice";
    String sayHello() { return super.sayHello() + ", " + name; }
    public static void main(String[] args) {
        System.out.println(new PersonalizedGreeting().sayHello());
    }
}
A

Hello, Alice

B

HelloAlice

C

Alice

D

Compilation Error

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|