Java – what is the difference between extending abstract classes and non abstract classes?
•
Java
What is the difference between abstract and non abstract classes when extending derived classes? Both classes do not use override methods and abstract methods (that is, abstract classes) I just inherited the attribute What and why do you prefer classes?
For example:
Code 1:
abstract class a{ protected int empnno; protected String empname } class b extends a { ...}
Code 2:
class a{ protected int empnno; protected String empname } class b extends a { ...}
Solution
Abstract classes may have abstract methods Abstract methods are methods that have no implementation. These methods must be implemented by your subclass (unless your subclass is also abstract)
Since your class has no abstract methods, it makes no difference from a subclass point of view (the only difference is that if a is abstract, it may not be instantiated as it is now. It can only be instantiated with subclasses.)
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码