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

Method Overriding and Overloading

Mark
< Prev
Next >

What is printed when the following code is executed?

class Parent {
    void foo(int a) { System.out.print("Parent int "); }
    void foo(double a) { System.out.print("Parent double "); }
}
class Child extends Parent {
    void foo(int a) { System.out.print("Child int "); }
}
public class Main {
    public static void main(String[] args) {
        Parent obj = new Child();
        obj.foo(5);
        obj.foo(5.0);
    }
}
A

Parent int Parent int

B

Child int Parent double

C

Parent int Parent double

D

Child int Child int

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|