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

Static Methods and Inheritance

Mark
< Prev
Next >

Consider the following class declarations.

public class Animal {
    public static void makeSound() {
        System.out.println("Some generic animal sound");
    }
}

public class Dog extends Animal {
    public static void makeSound() {
        System.out.println("Bark");
    }
}

The following code segment is executed in a method of a class other than Animal or Dog.

Animal animal = new Dog();
animal.makeSound();

What is the output when the code segment is executed?

A

Nothing is printed because the code does not compile.

B

Some generic animal sound

C

Some generic animal sound
Bark

D

Bark

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|