Java Programming- Example of Abstract Class and Abstarct Method

//Abstract Class is a class which contains atleast one abstract method. Abstract class cannnot be instantiated i.e. object cannot be created for that class. The methods are implemented in the subclass or base class.



import java.io.*;

abstract class Shape //Abstract Class
   {
    abstract void draw(); //Abstract Method
   }

class Rectangle extends Shape{

void draw()
  {
    System.out.println("Draw Rectangle Here");
  }
}

class Traingle extends Shape
   {

    void draw()
      {
        System.out.println("Draw Traingle Here");
      }
}

class AbstractClass Example
   {
    public static void main(String args[])
      {
       //Shape s=new Shape();//This ia Illegal Now
      Shape ob1=new Rectangle();
       ob1.draw();
       Shape ob2=new Traingle();
       ob2.draw();
      }
}
OUTPUT

Comments

Popular posts from this blog

Solution to Moodle Error: Coding error detected, it must be fixed by a programmer: Failed to unserialise data from file. Either failed to read, or failed to write.

ACTION_FAILED:OU_INVALID: Solution for GoogleApps bulk user upload issue, username@domainname.com:ACTION_FAILED:OU_INVALID. This error is because you have not specified the Org Unit Path properly.

(Solved) (Fixed )MariaDB Unmet Dependencies on Ubuntu 20.04.