| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy Solved by 4 students
Method Overriding with Super Keyword
< Prev
Next >

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

Compilation Error

B

HelloAlice

C

Hello, Alice

D

Alice

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