| 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 3 students
Method Overriding and Overloading
< 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 Child int

C

Parent int Parent double

D

Child int Parent double

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: apfive@apfive.org|Privacy Policy