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

Consider the following class definitions. What is printed when the main method of the SubClass class is executed?

class SuperClass {
    public String greet() {
        return "Hello";
    }
}

class SubClass extends SuperClass {
    @Override
    public String greet() {
        return super.greet() + " World";
    }
    
    public static void main(String[] args) {
        SubClass obj = new SubClass();
        System.out.println(obj.greet());
    }
}
A

Compilation Error

B

Hello

C

World Hello

D

Hello World

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2y.seong202711 0m 23s 77
#3psak1211 1m 38s 2
#4suhanakochhar00611 1m 54s -14
Items per page:
10
1 – 4 of 4
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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