Answers for "override methods in abstract class"

0

override abstract method java

public interface Order
{
    public boolean greaterThan(Order other);
}

public class AirCraft implements Order
{
   private String make;
   private int numSeats;

   public AirCraft(String make, int numSeats)
   {
      this.make = make;
      this.numSeats = numSeats;
   }

   public String getMake()
   {
      return make;
   }

   public int getNumSeats()
   {
      return numSeats;
   }

   @Override
   public boolean greaterThan(Order other)
   {
      AirCraft x = (AirCraft)other;
      return getNumSeats() > x.getNumSeats();
   }
   
   public String toString()
   {
       return make + " -> " + numSeats;
   }
}
Posted by: Guest on July-09-2020
2

abstract class example in java

//abstract parent class
abstract class Animal{
   //abstract method
   public abstract void sound();
}
//Dog class extends Animal class
public class Dog extends Animal{

   public void sound(){
	System.out.println("Woof");
   }
   public static void main(String args[]){
	Animal obj = new Dog();
	obj.sound();
   }
}
Posted by: Guest on November-11-2020

Code answers related to "override methods in abstract class"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language