| 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
< 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 Derived

B

Compilation Error

C

Hello from Base

D

Hello from Derived Hello from Base

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
#1sgarv251323 0m 00s 190
#2mali.nehme11 0m 00s 100
#3jaimonjosh11 1m 40s 0
Items per page:
10
1 – 3 of 3
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy