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

Create a class of your choosing in Java. This class should be the most basic ver

ID: 3858555 • Letter: C

Question

Create a class of your choosing in Java. This class should be the most basic version definition for the entity that you choose. For instance, should you choose a car, you would not create a "hybrid class", because that is not the most pure definition you could create for the car (i.e., there are cars that are not hybrid). In the header of your file, explain why you designed the class in your particular way. Why did you choose the attributes, the methods, and how the class might be useful for a user? In this part of the project, you will write the interface and then provide a test program (a main) to show that you are able to create viable objects. You should be able to set values for the attributes provided by a user and get the values from the interface to display for the user [output should be formatted].

Explanation / Answer

The program you require is as follows. I have tried to keep it simple to make you understand the use of interface in the real life programming.As we all know Java was introduced so that it would give a feel of real life programming features and interface is one of the features which makes it possible. Hence, it is one of the most important part of the programming construct in JAVA.

Mammal.java

public class Mammal implements Animals {

public void eating() {
System.out.println("Mammal is eating");
}

public void travelling() {
System.out.println("Mammal is travelling");
}

public int numLegs() {
return 0;
}

public static void main(String args[]) {
Mammal m = new Mammal();
m.eating();
m.travelling();
}
}

The class Mammal is an interface to the program which defines the working of the mammals like their daily tasks or in simple words common task they perform the whole day. In which eating and travelling is the must job. Hence, we deal with these two properties of the mammal in the interface. It becomes easy for the user to inherit the same properties in many similar classes like Mammal.

Hence, this is the use of the interface in Java.

Please rate the answer if it helped.....Thankyou

Hope it helps.....

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