Advertisement
JackHoughton00

Chapter 9 Work

May 11th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.70 KB | None | 0 0
  1. 1a) Inheritance allows a class to define a specialized type of an already existing class.
  2. 1b) Classes that are derived from existing classes demonstrate an is-a relationship. A class β€œis a” type of another class. In this case, a disk is a circle with a thickness.
  3. 1c ) A class that inherits another class includes the keyword extends in the class declaration.
  4. 1d) Designing a subclass requires selecting the superclass, or base class, and then defining any additional variable and method members for the subclass.
  5. 1e) In many cases, existing methods in the base class will also be overridden by the new definitions in the subclass, also called the derived class.
  6. 1f ) In a subclass, the keyword super is used to access methods of the base class. For example, the statement super(r) calls the constructor of the superclass, Circle, and passes an argument for setting the radius value.
  7. 1g) Polymorphism is an OOP property in which objects have the ability to assume different types. In object-oriented programming, polymorphism is based on inheritance.
  8. 1h) An abstract class models an abstract concept. For example, a musical instrument is an abstract concept. An instrument is something that can be played, but there is no such thing as an β€œinstrument” instrument. There are, however, flutes, piccolos, drums and cymbals.
  9. 1i) An abstract method is declared with the keyword abstract and contains a method declaration, but no body.
  10. 1j) The comparable interface is part of the java.lang package. It contains one method.
  11.  
  12. 2. The disk takes what is in the circle class and expands upon it. For example, it may add another variable that the circle class does not have while still using all the data that the circle class.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement