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

What is printed when the following code segment is executed?

class Base {
    public void method(Number n) {
         System.out.println("Base Number");
    }
}

class Derived extends Base {
    public void method(Integer n) {
         System.out.println("Derived Integer");
    }
}

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

Compilation Error

B

Base NumberDerived Integer

C

Base Number

D

Derived Integer

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