Home Abstraction in java

Abstraction in java

Process of hiding details and showing information to user.

1.Abstract Methods : – There is no body methods call as Abstract Methods.

2.Abstract Classes : – if the class has only one Abstract Method that class called as Abstract Class

3.Fully Abstract Classes  : – if the class consist of all methods Abstract class called as Fully Abstract Classes

4.Interfaces : Fully Abstract Classes = Interface

create a class Human

Human.java

public abstract class Human {

    public abstract void myMethod();

    public void testMethod()
    {
        System.out.println("Hiiiiiiiii");
    }
}

Member.java

//inherit from Human
public class Member extends Human {
    @Override
    public void myMethod() {
        System.out.println("test1111111");
    }
}

Main.java

public class Main {
    public static void main(String args[])
    {
        Member member = new Member();
        member.myMethod();
    }

}

 

Comments are closed.