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

Polymorphism and Method Overriding

Mark
< Prev
Next >

What is printed as a result of executing the following program?

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

StartA

B

Compilation Error

C

BStart

D

StartB

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|