Which of the following is the correct header for a class Penguin that extends Bird and implements interface Swims?Group of answer choicespublic class Penguin extends Bird implements Swims { }public class Penguin extends Swims implements Bird { }public class Penguin inherits Birdinherits
Added by Sofia B.
Step 1
Let's think step by step. Show more…
Show all steps
Your feedback will help us improve your experience
Manik Pulyani and 59 other AP CS educators are ready to help you.
Ask a new question
Labs
Want to see this concept in action?
Explore this concept interactively to see how it behaves as you change inputs.
Key Concepts
Recommended Videos
Consider the following hierarchy of classes: A program is written to print data about various birds: Assuming that none of the given classes is abstract and all have default constructors, which of the following segments of $/ * more code */ $will not cause an error? (A) printName(parrot2); printBirdCall((Parrot) bird2); (B) printName((Parrot) bird1); printBirdcall(bird2); (C) printName(bird2); printBirdcall(bird2); (D) printName((Parakeet) parrot1); printBirdcall(parrot2); (E) printName((Ow1) parrot2); printBirdcall((Parakeet) parrot2);
Consider the Animal, Bird, and Cardinal classes shown below. Which of the following object declarations will compile without error? public class Animal { /* constructors and methods not shown */ } public class Bird extends Animal { /* constructors and methods not shown */ } public class Cardinal extends Bird { /* constructors and methods not shown */ } Cardinal red = new Cardinal(); Animal tweety = new Bird(); Bird chirpy = new Cardinal(); I only II only III only I, II and III II and III only
Eduard S.
```java /** * SOFE 2710 Assignment 2 */ package airporttest; import java.util.ArrayList; public class Aircraft { private String name; private String state; private String flightState; private ArrayList<Pilot> pilots; public Aircraft(String name, String state, String flightState, ArrayList<Pilot> pilots) { this.name = name; this.state = state; this.flightState = flightState; this.pilots = pilots; } public String getName() { return name; } public String getState() { return state; } public String getFlightState() { return flightState; } public void joinPilot(Pilot pilot) { pilots.add(pilot); } public void printPilots() { for (Pilot pilot : pilots) { System.out.println(pilot.toString()); } } } ```
Akash M.
Recommended Textbooks
Computer Science and Information Technology
Introduction to Programming Using Python
Computer Science - An Overview
Transcript
Watch the video solution with this free unlock.
EMAIL
PASSWORD