Heranca Com Java
Heranca Com Java
A concrete class is one from which you can instantiate objects. Sometimes,
a class is so general
that you never intend to create any specific instances of the class. For
example, you might
intend never to create an object that is “just” an Employee; each Employee is
more specifically
a SalariedEmployee, HourlyEmployee, or ContractEmployee. A class such as
Employee that
you create only to extend from is not a concrete class; it is an abstract class.
In Chapter 10, you
learned that you can create final classes if you do not want other classes to be
able to extend
them. Classes that you declare to be abstract are the opposite; your only
purpose in creating
them is to enable other classes to extend them. If you attempt to instantiate an
object from an
abstract class, you receive an error message from the compiler that you have
committed an
InstantiationError. You use the keyword abstract when you declare an abstract
class.
(In other programming languages, such as C++, an abstract class i