Solutions for Exam I:
Ch1:
Answers to Review Questions
1.
The analysis, design, and
implementation of information systems using object-oriented programming
languages, technologies, and techniques is:
a.
Object-oriented development
2.
OO development includes which of
the following?
c.
OOA, OOD, and OOP
3.
Which of the following is NOT an
example of an OO programming language?
b.
Pascal
4.
The first pure general-purpose OO
language was:
a.
SmallTalk
5.
UML is an acronym for:
b.
Unified Modeling Language
6.
A model-driven approach to
development is used for:
d.
Both traditional and OO development
7.
Which of the following is NOT a
technique used in both traditional and OO development?
d.
Class diagramming
8.
Which of the following is NOT a
diagram defined by UML?
a. Entity-relationship diagram
9.
An object-oriented system is
defined as:
a.
a collection of interacting objects that accomplish tasks
10.
A thing that has attributes and
behaviors is called a(n):
c.
object
11.
A characteristic of an object that
takes on a value is called a(n):
d.
Attribute
12.
What an object is capable of doing
in terms of behavior is called a(n):
d.
Method
13.
Objects that make up the user
interface to the system are called:
c.
GUI objects
14.
Objects
that are specific to the business application
are called:
a.
Problem domain objects
15.
A request sent asking an object to
invoke, or carry out, one of its methods is called a(n):
d.
Message
16.
Encapsulation hides the internal
structure of objects and protecting them from corruption. This is also referred
to as:
a.
Information hiding
17.
Each object has a unique address,
meaning you can find it, or refer to it, and send it a message. This is referred
to as the:
d.
Object identity
18.
Persistent objects are those that:
a.
Are available to use over time
19.
A class and an object are:
d. different because a class is a type of thing
and an object is a specific instance
20.
Which of the following is an
association relationship?
c. A customer enrolls in a credit program
21.
The number of associations possible
between classes of objects is called:
b.
Multiplicity
22.
An example of a superclass of the
class Car is:
a. Motor vehicle
23.
An example of a subclass of the
class Truck is:
d. Dump truck
24.
Polymorphism means that a blender
and a washing machine:
b.
Can both be told to spin
25.
The two benefits of OO development
are:
a. Naturalness and reuse
26.
Three-tier design divides the
system in the following categories of classes:
c.
Problem domain classes, GUI classes, and data access classes
Ch2:
Answers to Review Questions
1.
What is bytecode? What is its
benefit?
Bytecode is the name of the code produced when you compile a Java source
program. It is read and executed by the JVM.
Bytecode gives Java platform independence.
2.
What is the
JVM? What does it do?
The Java Virtual Machine is an interpreter that reads and executes bytecode.
3.
When you see two file names such as
Demo.java and Demo.class, what do the extensions class and java indicate?
An extension of “.java” indicates the file is a source program.
An extension of “.class” indicates the file is bytecode.
4.
What is an
IDE?
An Integrated Development Environment is a set of software tools that facilitate
the development and debugging of software.
5.
What is a Java identifier? What are
the rules for creating one?
A Java identifier is the name of a Class, Method, or Variable and can be any
length, can include any character except space, and must begin with a letter of
the alphabet, a dollar sign ($) or the underscore character (_).
6.
What is the
purpose of a block of code?
A block of code consists of statements between an opening curly brace ({) and
closing curly brace (}). Blocks are used to contain class definitions, methods,
loops, and other types of code.
7.
What is a
Java keyword?
A Java keyword is a word that has special meaning in a programming language and
is used in writing statements.
8.
What is a
primitive variable?
A primitive variable is a variable is declared with one of
the eight primitive data types.
9.
What is the
error in the statement: float d = 2.5;
The literal value 2.5 needs to have the letter ‘F’ placed after it to
indicate to the compiler that is data type float, otherwise the compiler assumes
it is double.
10.
How can you
tell if an identifier is a constant?
The keyword final
indicates a constant.
11.
What does
null mean?
null indicates no value.
12.
What is an
argument?
An argument is the data passed to a method.
13.
Explain the
difference between Java’s use of single and double quotes.
Java uses single quotes to indicate a character literal value and uses double
quotes to indicate a String literal value.
14.
What is the
main method?
If a class has a main method, it is automatically executed when the class is
loaded into memory.
15.
What does
the keyword new do?
It indicates to the compiler that you are creating a new instance.
16.
What is the
Java conditional operator?
The conditional operator (?) is used as a
shortcut to writing an if–else statement.
17.
Explain the
difference between the divide and the remainder operators.
The divide operator divides one value by another and a quotient results. The
remainder operator (modulus) divides one value by another and the remainder
results.
18.
What are the
limitations of switch?
There are two limitations. First, each case evaluates a single variable for
equality only. You cannot test less than or greater than expressions with
switch. Second, the variable being evaluated must be data type char, byte,
short, or int. None of the other data types can be used.
19.
What are the
two types of loops? How does Java implement each of these?
The two types of loops are pre-test and post-test. Java’s while and for are
pretest and the do is a post-test.
20.
What is an
index?
An index is an integer value that points to an array row, or column, or element,
or to a character in a string of characters.
Ch3:
Solutions to Review Questions
1.
The Java
Development Kit consists of approximately ____________ packages.
c.
75
2.
The Java
compiler automatically imports the
package.
d.
java.lang
3.
Java uses
double quotes to indicate you are writing:
a.
a String literal
4.
The term
“instantiating a class” means:
c.
creating an instance of the class
5.
Class
methods are also called:
a.
static methods
6.
The correct
statement to invoke the String valueOf method for primitive variable i is:
b.
String.valueOf(i);
7.
The index of
the first character of a String value is:
b.
0
8.
The String
valueOf method converts:
a.
primitive to String
9.
The wrapper method you use to
convert a double wrapper instance to a double primitive is.
c.
doubleValue
10.
The wrapper
method you use to convert a String to a wrapper instance is.
b.
valueOf
11.
Each element
in a String array is:
d.
It depends on the data type you specify.
12.
To obtain
the number of elements in a String array named sArray, you would write:
a.
sArray.length()
13.
String
values in Java:
a.
cannot be changed
14.
The elements
of a Vector:
a.
can contain only object references
15.
The Vector
method that returns the number of elements is:
c.
capacity
16.
Applet is a
subclass of:
d.
Panel
17.
What does
the Graphics method drawString do?
c.
Draws characters.
18.
Where is X =
0, Y = 0 on a Panel instance?
b.
Upper left.
19.
What is Color.red?
c.
A constant.
20.
An applet:
c.
A & B.
Ch4:
Answers to Review Questions
Ch5:
Answers to Review Questions
1.
What is a class definition?
A class definition is Java code written to model a class. It consists of
attribute definitions and methods.
3.
What are the conventions for
writing an identifier?
Class names are capitalized while variable and method names begin with a lower
case letter. When a name consists of more than one word, subsequent words are
capitalized. Method names generally contain a verb describing what the method
does.
14.
What causes a constructor method to
be invoked?
Instantiating a class using the keyword new.