Abstract Methods & Classes

By:Mohammad-Ali Bandzar | May 9 2019

An introduction to Abstraction with java

Abstract classes are classes that are declared as abstract. Abstract classes can only be used in sub classes. An abstract class is created without any actual functionality, with its main purpose being to reserve the class name for later use.

Any class that uses abstract methods must also have those methods declared as an abstract class.

Abstract classes are used when you want to share methods amoungst multiple classes. The subclass declaration must have the same name as the class declaration and will detetermine the methods functionality.

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

        class Cat extends Animal{

            public void sound(){
            public static void main(String args[]){
                Animal cA = new Cat();

credits:Mrs.Krastavas pickup folder