Java-depth exploration

As the saying goes Learning While Learning, Reviewing the Old, with the recent and not the same understanding of the basics of Java in the review process, so look at this record, note that this is only for reference oh! If anything had misunderstood the hope that we can correct, to discuss progress together.

Abstract classes and interfaces

  • Abstract classes and interfaces can not be instantiated directly.
  • An interface can contain only method declarations and constants, abstract classes and methods declared with a specific implementation may contain.
  • Variables defined in the interface can only be public static constants, the abstract class variables are common variables.
  • Abstract class can no abstract methods.
  • If there is a class abstract method, then this class is an abstract class only.
  • Abstract method to be implemented, it can not be static, it can not be private.
  • Interface inheritable interfaces, interfaces and multiple inheritance, but only single inheritance class.

I think in the abstract Java class package is mainly responsible for the role, and the interface is mainly responsible for the multi-state character, the interface is a convention, the interface implementation class to follow this convention, abstract class is a class, mainly for some countries with common a packaged object property or method.

Guess you like

Origin juejin.im/post/5d30748bf265da1b7638da24
Recommended