Documente Academic
Documente Profesional
Documente Cultură
Chapter 8
Section 8.1
Section 8.2
Section 8.3
Section 8.4
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 2 of 5
Section 8.5:
8.5 Q1: When should a program explicitly use the this reference:
a.Accessing a private variable.
b.Accessing a public variable.
c.Accessing a local variable.
d.Accessing a field that is shadowed by a local variable.
ANS: c. Accessing a field that is shadowed by a local variable.
Section 8.6
8.6 Q2: Which of the following will be used to create an instance of a class if the programmer does not define a
constructor?
a.A default constructor.
b.An overloaded constructor.
c.The Object class constructor with the name of the desired class passed in as an argument.
d.If no constructor is written, then one isn’t needed.
ANS: a. A default constructor.
Section 8.7
Section 8.8
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 3 of 5
8.8 Q2: Using public set methods provides data integrity if:
a.The instance variables are public.
b.The instance variables are private.
c.The programmer provides validity checking.
d.Both b and c.
ANS: d. Both b and c.
Section 8.9
Section 8.10
Section 8.11
Section 8.12
Section 8.13
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.
Java How to Program, 5/e Test Item File 4 of 5
Section 8.14
8.14 Q1: When no member access modifier is specified for a method or variable, the method or variable:
a.Is public.
b.Is private.
c.Has package access.
d.Is static.
ANS: c. Has package access.
Section 8.15
8.15 Q2: Which of the following does not contribute to improved software reusability?
a.Quickly creating new class libraries without testing them thoroughly.
b.Licensing schemes and protection mechanisms.
c.Descriptions of classes that allow programmers to determine whether a class fits their needs.
d.Cataloging schemes and browsing mechanisms.
ANS: Quickly creating new class libraries without testing them thoroughly.
Section 8.16
© Copyright 2003 by Deitel & Associates, Inc. and Prentice Hall. All Rights Reserved.