Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create an interface named Nameable that has the following methods: setName and g

ID: 3769869 • Letter: C

Question

Create an interface named Nameable that has the following methods: setName and getName Create an abstract class named Mammal that has an abstract method named makeNoise. Create a class named puppy that extends from Mammal and implements Nameable. Create another class named Car that implements Nameable, Comparable that compares the mileage and cloneable that clone name and mileage. Create a class named Planet that implements Nameable. Write a main to test them. You have to create all proper objects and call all proper methods.

Explanation / Answer

public interface Nameable {

String getName();

void setName (String aName);

}

public abstract class Mammal {

public abstract void makeNoise();

}

class Puppy extends Mammal implements Nameable {

String name;

public void makeNoise(){System.out.println("Bark");};

public void setName (String aName) {name = aName;};

public String getName () {return (name);};

}

class Planet implements Nameable {

String planetName;

public String getName() {return planetName;};

public void setName(String myName) {planetName = myName;};

}

class Car implements Nameable {

String carName;

public String getName() {return carName;};

public void setName(String myName) {carName = myName;};

}

class Test{

public static void main(String[] args)

{

Puppy P = new Puppy();

Mammal M = P;

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote