Are you taking CLEP classes? Try clep.ai
| 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

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

Base Number

B

Derived Integer

C

Compilation Error

D

Base NumberDerived 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.

AI Tutor

How can I help?

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