| preferred AP College board partner for AP classes
AP Computer Science A/Unit 9: Inheritance
Start Practice TestPractice Test
About Exam
easy Solved by 2 students
Indirect Superclass Inheritance
< Prev
Next >

Which of the following code segments correctly demonstrates a class inheriting a method from an indirect superclass?

A
public class LivingThing {
    public void breathe() { System.out.println("Breathing"); }
}

public class Animal extends LivingThing { }

public class Mammal {
    // Does not extend Animal
}
B
public class LivingThing {
    public void breathe() {
        System.out.println("Breathing");
    }
}

public class Animal extends LivingThing { }

public class Mammal extends Animal { }
C
public class LivingThing { 
    public void breathe() { System.out.println("Breathing"); } 
}

public class Animal { }

public class Mammal extends Animal { }
D
public class Animal {
    public void breathe() {
        System.out.println("Breathing");
    }
}

public class Mammal extends Animal { }
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: apfive@apfive.org|Privacy Policy