Abstract Data Type and Interface

前端 未结 8 1359
小鲜肉
小鲜肉 2021-02-04 18:26

I am new to Java. What is the difference between Abstract data type and Interface.

For Example We have a ListADT

interface MyListADT {
    void          


        
8条回答
  •  野性不改
    2021-02-04 19:11

    In java-

    interface can have only abstract method which means you can only declare the method i.e . method can have any default implementation.but abstract class can have both abstract or complete method.

    if the class you are extending is abstract then your child class should either be declared as abstract or should implement all abstract method of super class. In case -in interface you can implement as many interface you want.Here also you should implement all the abstract method of all the interfaces in your class or it should be declared as abstract.

    follow these link

    http://javapapers.com/core-java/abstract-and-interface-core-java-2/difference-between-a-java-interface-and-a-java-abstract-class/

    http://www.codeproject.com/Articles/11155/Abstract-Class-versus-Interface

    What is the difference between an interface and abstract class?

提交回复
热议问题