| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
hard Solved by 1 students
Polymorphism and Method Overloading
< Prev
Next >

What is the output when the main() method is executed?

public class Base {
    public void process(Base b) {
        System.out.println("Base");
    }
}

public class Derived extends Base {
    public void process(Derived d) {
        System.out.println("Derived");
    }
}

public class Main {
    public static void main(String[] args) {
        Base b = new Derived();
        b.process(b);
    }
}
A

Derived

B

Compilation Error

C

Base Derived

D

Base

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