java - Do/can abstract classes replace interfaces? -


In Java, you can create an abstract class that contains only abstract methods. On the other hand, you can create an interface that Announces similar methods. This is the case, can you use an abstract class instead of the interface?

Not always:

  • One class only one < / Em> class
  • more than one interface

Compare more:

Table class versus interfaces

Unlike the interface, the intangible category may contain fields that are static and not the last, and these may be applicable methods. Such intangible classes are similar to the interface, except that they provide a partial implementation, it is left in subclasses to complete the implementation. If there is only abstract method announcements in an abstract category, then it should be declared as an interface instead.

Multiple class transit class can be applied anywhere in class, whether it is related to some other way. Think about comparative or cloning, for example.

By comparing, the intangible sections are most sub-classified to share the implementation pieces. A single abstract class is sub-classified by the same classes, in which there is a lot of common (incompatible sections of the incompatible sections), but there are some differences (abstract elements) too.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -