| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
Share
About Exam
medium Solved by 5 students
Polymorphism and Method Overriding
< Prev
Next >

What will be printed when the program is executed?

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

Compilation Error

B

Animal Bark

C

Animal

D

Bark

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1kaisuki11 0m 00s 100
#2chrislee127411 0m 37s 63
#3lsj0803092211 3m 31s -111
Items per page:
10
1 – 3 of 3

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy