G.14. Wrap-Up

We introduced inheritance—the ability to create classes by absorbing an existing class’s members and embellishing them with new capabilities. You learned the notions of superclasses and subclasses and used keyword extends to create a subclass that inherits members from a superclass. We showed how to use the @Override annotation to prevent unintended overloading by indicating that a method overrides a superclass method. We introduced the access modifier protected; subclass methods can directly access protected superclass members. You learned how to use super to access overridden superclass members. You also saw how constructors are used in inheritance hierarchies. Next, you learned about the methods of class Object, the direct or indirect superclass of all Java classes.

We discussed polymorphism—the ability to process objects that share the same superclass in a class hierarchy as if they’re all objects of the superclass. We considered how polymorphism makes systems extensible and maintainable, then demonstrated how to use overridden methods to effect polymorphic behavior. We introduced abstract classes, which allow you to provide an appropriate superclass from which other classes can inherit. You learned that an abstract class can declare abstract methods that each subclass must implement to become a concrete class and that a program can use variables of an abstract class to invoke the subclasses’ implementations of abstract methods polymorphically. You also learned how to determine an object’s type at execution time. We discussed the concepts of final methods and classes. Finally, we discussed declaring and implementing an interface as another way to achieve polymorphic behavior.

You should now be familiar with classes, objects, encapsulation, inheritance, polymorphism and interfaces—the most essential aspects of object-oriented programming.

Next, you’ll learn about exceptions, useful for handling errors during a program’s execution. Exception handling helps you build more robust programs.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset