JAVA CLASS AND OBJECT JAVA JAVA JAVA Write a java program/code of the given problems below: abstract class Animal { // abstract methods abstract void move(); abstract void eat(); // concrete method void label() { System.out.println("Animal's data:"); } } 1.) Modify the abstraction example code above by adding another class “TestCarabao” with the necessary methods “label, move, and eat”. 2.) Write a program that creates a car object, and displays the year and name with one method “speed”. Example output: Year: 2021 Model: Toyota Speed: 200km/h 3.) Write the main class of the given class Animal below that set the number of legs to “4” and display (get) the number of legs. class Animal { private int numberOfLegs; public void setNumberOfLegs(int numberOfLegs) { this.numberOfLegs = numberOfLegs; } public int getNumberOfLegs() { return numberOfLegs; } }
JAVA CLASS AND OBJECT
JAVA JAVA JAVA
Write a java program/code of the given problems below:
abstract class Animal {
// abstract methods
abstract void move();
abstract void eat();
// concrete method
void label() {
System.out.println("Animal's data:");
}
}
1.) Modify the abstraction example code above by adding another class “TestCarabao” with the
necessary methods “label, move, and eat”.
2.) Write a program that creates a car object, and displays the year and name with one method “speed”.
Example output:
Year: 2021
Model: Toyota
Speed: 200km/h
3.) Write the main class of the given class Animal below that set the number of legs to “4” and display (get) the number of legs.
class Animal {
private int numberOfLegs;
public void setNumberOfLegs(int numberOfLegs) {
this.numberOfLegs = numberOfLegs;
}
public int getNumberOfLegs() {
return numberOfLegs;
}
}
Step by step
Solved in 3 steps with 1 images