Home > Back-end >  Interface class abstract classes
Interface class abstract classes

Time:09-26

An abstract class can inherit an interface (extends)? An entity class can inherit an interface? An abstract class can inherit entity class? Abstract class inheritance entity class have a purpose?

CodePudding user response:

You spend 300 q, I suggest you write it again be clear at a glance

CodePudding user response:

Interface no inheritance of said, is to implement, an abstract class can implement interfaces, similarly, an entity class can implement interfaces,
An abstract class can inherit entity class, the class itself and abstraction, the entity has nothing to do, as long as it's not the final definition of class can inherit,
Class itself is for the sake of code reuse and polymorphism, so abstract class inheritance entity class is to directly use the function of the original entity class, can be expanded on the basis of its,

CodePudding user response:

The
refer to the original poster a 223317 response:
an abstract class can inherit an interface (extends)? An entity class can inherit an interface? An abstract class can inherit entity class? Abstract class inheritance entity class have a purpose?


An abstract class can implement (implement) one or more interfaces, and not have to implement the interface declarations inside all methods of
An entity class can implement (implement) one or more interfaces, must implement the interface all methods declared inside,
An abstract class can be integrated, an entity class, if this be inherited entity class is not declared as final, or have no private constructor,
Inheritance is a major feature of object-oriented programming, used to organize structure and interaction between the classes

CodePudding user response:

Can, interface is realized, and a class can implement multiple interfaces and inheritance for is the polymorphism, the same kind of method for different objects, different implementation, both entities inherit to the abstract or abstract entities, such as men and women inherit the human, has inherited the working method of the human, men work is to move the brick, women work is embroidery, this is the embodiment of the polymorphic,
A lot of API source, is everywhere, you go and see yourself, understand, according to write a few examples to understand,

CodePudding user response:

Several layers above the basic right, but have a bit, interfaces can be inherited

CodePudding user response:

The
refer to the original poster a 223317 response:
an abstract class can inherit an interface (extends)? An entity class can inherit an interface? An abstract class can inherit entity class? Abstract class inheritance entity class have a purpose?

Interface no inheritance of said, is to implement, an abstract class can implement interfaces, similarly, an entity class can implement interfaces,
An abstract class can inherit entity class, the class itself and abstraction, the entity has nothing to do, as long as it's not the final definition of class can inherit,

CodePudding user response:

The same question 2 times? Reply this post, you still not satisfied?
https://bbs.csdn.net/topics/396334699

CodePudding user response:

refer to 7th floor paullbm response:
the same question 2 times? Reply this post, you still not satisfied?
https://bbs.csdn.net/topics/396334699

Two problems are different??

CodePudding user response:

Interface: before JDK7.0 there can only be abstract method, 8.0 adds a static method and the default method, 9.0 added a private method, so the interface can't be inherited can only be achieved, a class can implement one or more interfaces, if the class implementing an interface (probably more) among them are part of the abstract methods (even if only one) is not implemented, this class can only be abstract class, if you want to define an entity class, you must implement all abstract methods,
Abstract: can have abstract methods, also can not abstract method,
Entity class: there can be no abstract methods,
Abstract classes and entity class can inherit and only the entity class to inherit an abstract class must implement all abstract class abstraction method, Java allows only single inheritance, also is a kind of only one parent,
Abstract class inheritance function entity class one is don't have to rewrite the entity class member variables and related methods that have been defined, but can add their own member variables and methods (including an abstract method), if defines the abstract method, indicate the class defines a new standard,

CodePudding user response:

Write code to run more, believe in the truth
  • Related