Java Reference
In-Depth Information
7 . In general, while writing the definitions of the methods of a subclass to
specify a call to a public method of a superclass, we do the following:
￿ If the subclass overrides a public method of a superclass, then you
specify a call to that public method of the superclass by using the
reserved word super , followed by the dot operator, followed by the
method name with an appropriate parameter list.
￿ If the subclass does not override a public method of the superclass, you
can specify a call to that public method by using the name of the
method and an appropriate parameter list.
8 . Ifamethodofaclassisdeclared final , it cannot be overridden in any subclass.
9 . While writing the definition of a constructor of a subclass, a call to a
constructor of the superclass is specified using the reserved word super
with an appropriate parameter list. Moreover, the call to a constructor of
the superclass must be the first statement.
10 . Typically, when a subclass constructor executes, first a constructor of the
superclass executes to initialize the data members inherited from the super-
class and then the constructor of the subclass executes to initialize the data
members declared by the subclass.
11 . For a superclass to give direct access to its member(s), to its subclass(es), and
still prevent its direct access outside the class, such as in a user program, you
must declare that member using the modifier protected . In fact, a class
member declared with the modifier protected may be accessed by any
class in the same package.
12 . If a member of a class has a package access, that member can be directly
accessed in any class contained in that package, but not in any class that is
not contained in that package even if a subclass is derived from the class
containing that member and the subclass is not contained in that package.
13 . If you define a class and do not use the reserved word extends to derive it
from an existing class, then the class you define is automatically considered
to be derived from the class Object .
14 . The class Object directly or indirectly becomes the superclass of every
class in Java.
15 . The class es Scanner , Reader , and Writer are derived from the class
Object . The class InputStreamReader is derived from the class
Reader , and the class FileReader is derived from the class
InputStreamReader . Similarly, the class PrintWriter is derived from
the class Writer .
16 .
Java allows us to treat an object of a subclass as an object of a superclass; that is, a
reference variable of a superclass type can point to an object of a subclass type.
17 .
In a class hierarchy, several methods can have the same name and the same
formal parameter list.
Search WWH ::




Custom Search