Lab Task 002
Lab Task 002
Question 01:
class Vehicle{
public void move()
{
System.out.println("The vehicle is moving");
}
}
class Car extends Vehicle{
public void move()
{
super.move();
System.out.println("The car is moving");
}
}
class Bike extends Vehicle
{
public void move() {
super.move();
System.out.println("The bike is moving");
}
}
public class Main {
public static void main(String[] args)
{
Vehicle myCar =new Car();
Vehicle myBike =new Bike();
myCar.move();
myBike.move();
}
}
Output:
Question 02:
class Animal {
public void makeSound() {
System.out.println("Animals make sounds");
}
}
Output:
Question 04:
class Employee {
void calculateBonus() {
System.out.println("Calculating base employee bonus");
}
}
Output: