Java Multiple Inheritance

前端 未结 17 1457
猫巷女王i
猫巷女王i 2020-11-22 09:36

In an attempt to fully understand how to solve Java\'s multiple inheritance problems I have a classic question that I need clarified.

Lets say I have class Ani

17条回答
  •  没有蜡笔的小新
    2020-11-22 10:30

    To solve the problem of mutiple inheritance in Java → interface is used

    J2EE (core JAVA) Notes By Mr. K.V.R Page 51

    Day - 27

    1. Interfaces are basically used to develop user defined data types.
    2. With respect to interfaces we can achieve the concept of multiple inheritances.
    3. With interfaces we can achieve the concept of polymorphism, dynamic binding and hence we can improve the performance of a JAVA program in turns of memory space and execution time.

    An interface is a construct which contains the collection of purely undefined methods or an interface is a collection of purely abstract methods.

    [...]

    Day - 28:

    Syntax-1 for reusing the features of interface(s) to class:

    [abstract] class  implements ,.........
    {
        variable declaration;
        method definition or declaration;
    };
    

    In the above syntax clsname represents name of the class which is inheriting the features from ‘n’ number of interfaces. ‘Implements’ is a keyword which is used to inherit the features of interface(s) to a derived class.

    [...]

    Syntax-2 inheriting ‘n’ number of interfaces to another interface:

    interface  extends ,.........
    {     
        variable declaration cum initialization;
        method declaration;
    };
    

    [...]

    Syntax-3:

    [abstract] class  extends  implements ,.........
    {
      variable declaration;
      method definition or declaration;
    };
    

提交回复
热议问题