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
medium Solved by 4 students

Polymorphism and Method Overriding

Mark
< Prev
Next >

What is printed as a result of executing the following code segment?

class Animal {
    void sound() { System.out.print("Animal "); }
}
class Dog extends Animal {
    void sound() { System.out.print("Bark "); }
}
public class Main {
    public static void main(String[] args) {
        Animal a = new Dog();
        a.sound();
    }
}
A

Bark

B

Compilation Error

C

Animal

D

Animal Bark

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1zgj0731041722 1m 14s 126
#2kaisuki11 0m 00s 100
#3chrislee127411 0m 37s 63
#4lsj0803092211 3m 31s -111
#5chunxiangxu.cxu01 11m 45s -715
Items per page:
10
1 – 5 of 5

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|