| 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
Polymorphism and Method Overriding
< Prev
Next >

What will be printed when the program is executed?

class A {
    public String fun() { return "A"; }
    public String fun(String s) { return s + "A"; }
}

class B extends A {
    public String fun() { return "B"; }
    public String fun(String s) { return s + fun(); }
}

public class Main {
    public static void main(String[] args) {
         A obj = new B();
         System.out.println(obj.fun("Start"));
    }
}
A

StartB

B

Compilation Error

C

BStart

D

StartA

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