Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
hard Solved by 3 students

Method Overriding in Constructor Call

Mark
< Prev
Next >

What is printed when the following code is executed?

class Base {
    Base() { greet(); }
    void greet() { System.out.print("Hello from Base "); }
}
class Derived extends Base {
    Derived() { }
    void greet() { System.out.print("Hello from Derived "); }
}
public class Main {
    public static void main(String[] args) {
        new Derived();
    }
}
A

Hello from Base

B

Hello from Derived

C

Hello from Derived Hello from Base

D

Compilation Error

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1sgarv251323 0m 00s 190
#2mali.nehme11 0m 00s 100
#3jaimonjosh11 1m 40s 0
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

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