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 Solved by 1 students

Inheritance and Method Overloading

Mark
< Prev
Next >

Consider the following class declarations. What is the output when the main method of the Test class is executed?

class A {
    public void foo(int x) {
        System.out.println("A");
    }
}

class B extends A {
    public void foo(double x) {
        System.out.println("B");
    }
}

public class Test {
    public static void main(String[] args) {
        B b = new B();
        b.foo(5);
    }
}
A

No output

B

B

C

Compilation Error due to ambiguous call

D

A

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|