50 likes | 275 Views
Abstract Classes and Methods. An abstract class is one which the programmer never intends to instantiate. Concrete classes, classes intended to be instantiated. Abstract classes. Too generic to create real objects Reduce dependency on concrete class code Made abstract by key word “abstract”
E N D
Abstract Classes and Methods An abstract class is one which the programmer never intends to instantiate. Concrete classes, classes intended to be instantiated.
Abstract classes • Too generic to create real objects • Reduce dependency on concrete class code • Made abstract by key word “abstract” • Contains abstract methods ( cannot be static) • Abstract methods do not contain implementations.
Example abstract class Public abstract class Shape exends Object{ Public double getArea() { return 0.0; } Public double getVolume() { return 0.0; } Public abstract String getName(); }
Abstract Classes • JHTP chapter 10 slides 16-34
Interface • Jhtp chapter 10 51-59