Programming and Problem Solving with Java

(やまだぃちぅ) #1

368


10.What do we call the rules that determine where in a program an identifier can
be recognized? (p. 339)
11.What keyword refers to a class’s superclass? (p. 349)
12.What keyword allows an object to refer to itself? (pp. 341–342)
13.What is the name of the file class that outputs objects? (pp. 354–358)
14.What is the name of the file class that inputs objects? (pp. 354–358)

Answers
1.Object2.Inheritance 3.Derived class 4.instance; class 5.private6.Polymorphic operation 7.Class construc-
tors are not inherited.8.derived; super 9.extendstells the compiler the class from which this class is being
derived.10.Scope rules 11.super12.this13.ObjectOutputStream14.ObjectInputStream

Exam Preparation Exercises



  1. a.Name two kinds of scope.
    b.Do both internal and external scope depend on the access modifiers of an
    identifier?
    c. Define internal scope.
    d.What are the two exceptions that apply to internal access of members?
    e.What is shadowing?
    f. Is it legal to define local variables with the same identifier in nested blocks?
    2.Name the three external places from which Java allows class members to be
    accessed.

  2. a.List the four levels of access for class members.
    b.Which of the four levels is the default access?
    c. From where can a publicmember be accessed?
    d.From where can a member with no access modifier be accessed?
    e.From where can a privatemember be accessed?
    f. From where can a protectedmember be accessed?

  3. a.What nonpublic members should be part of the inheritance interface?
    b.How do you make them part of the inheritance interface?
    5.What happens if we forget to include a constructor in a new class?

  4. a.Distinguish between a deep copy and a shallow copy.
    b.Under what conditions are a deep copy and a shallow copy the same?
    7.To which class can all Java objects trace themselves back?
    8.What modifier of a class or field indicates that it is incomplete?
    9.What does the inheritance mechanism allow one class to acquire from
    another?
    10.What do you call the class that is extended by a derived class?

Free download pdf