Question: JAVA - Type the program's output: public class TestAnimal { public static void main ( String [ ] args ) { Domestic myDomestic = new
JAVA
Type the program's output:
public class TestAnimal
public static void mainString args
Domestic myDomestic new DomesticSpot "James";
Wild myWild new WildSimba "Lion";
myDomestic.printInfo;
System.out.println;
myWild.printInfo;
public abstract class Animal
protected String name;
protected int age;
abstract void printInfo;
public String getNameAndAge
return this.age years, name;
public class Domestic extends Animal
private String owner;
public DomesticString domesticName, int domesticAge, String domesticOwner
this.name domesticName;
this.age domesticAge;
this.owner domesticOwner;
public void printInfo
String nameAndAge this.getNameAndAge;
System.out.printlnnameAndAge;
System.out.printlnOwner: this.owner;
public class Wild extends Animal
private String species;
public WildString wildName, int wildAge, String wildSpecies
this.name wildName;
this.age wildAge;
this.species wildSpecies;
public void printInfo
String nameAndAge this.getNameAndAge;
System.out.printlnnameAndAge;
System.out.printlnSpecies: this.species;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
