Question: Q1: Create a program with a superclass called Animal that has a method called animalSound(). Subclasses of Animals could be Cows, Cats, Dogs, Birds -
Q1: Create a program with a superclass called Animal that has a method called animalSound(). Subclasses of Animals could be Cows, Cats, Dogs, Birds - And they also have their own implementation of an animal sound (the cow moo's, the cat meows, etc.): Q2: Define the subclass and the super class in the following code, and write the expected output. class Vehicle protected String brand - "Ford"; // Vehicle attribute public void honkl) { // Vehicle method System.out.println("Tuut, tuut!"); 1 } class Car extends Vehicle private String modelName - "Mustang"; // Car attribute public static void main(String[] args) { // Create a myCar object Car myCar - new Car(); // Call the honk() method (from the Vehicle class) on the myCarobject TyCarbonk); // Display the value of the brand attribute (from the Vehicle class) and the value of the model Name from the Car class System.out.println(myCar brand + + myCar.modelName)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
