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

1.     A model is:

b.     A representation of some aspect of the real world

 

2.     In OO development, a model is:

b.     Something created during both OOA and OOD

 

3.     Systems analysis means to:

a.     Define what the system needs to accomplish for users in business terms

 

4.     System design means to:

c.     Create models showing how the various system components will be implemented with specific technology

 

5.     Creating logical models of the system requirements during analysis and then physical models during design is idea behind:

b.     Model-driven development

 

6.     Some of the system is completed and put into operation before the entire system is finished when using:

c.     Incremental development

 

7.     To emphasize the iterative nature of development, the project is shown as a spiral starting in the middle and working out when using:

d.     Spiral development

 

8.     Grady Booch, James Rumbaugh, and Ivar Jacobson are the individuals responsible for defining and standardizing:

b.     The unified modeling language (UML)

 

9.     The UML diagram that shows the system users and system functions is called the:

a.     Use case diagram

 

10.   The UML diagram that shows the classes of objects involved in the system is called the:

b.     Class diagram

 

11.   The UML diagram that shows how objects interact is called the:

c.     Sequence diagram

 

12.   There are many other UML diagrams that are not shown in this chapter, for example the:

d.     Activity diagram

 

 

13.   The class diagram is an example of a:

d.     Static model

 

14.   The sequence diagram is an example of a:

b.     Dynamic model

 

15.   On a class diagram, the lines that are drawn to connect two classes represents a(n)

c.     Association relationship

 

16.   Which of the following represents optional one to one multiplicity?

c.     0..1

 

17.   Which of the following represents mandatory one to many multiplicity?

b.     1..*

 

18.   On a class diagram, the symbol representing a generalization/specialization hierarchy is:

b.     A triangle pointing to the superclass

 

19.   On a sequence diagram, an activated object is represented as:

d.     A narrow box on the lifeline

 

20.   On a sequence diagram, an actor is represented as:

b.     A stick figure

 

21.   The three tiers in three tier design include all of the following EXCEPT:

a.     The operating system tier

 

22.   In three-tier design, the first tier considered is the:

c.     The problem domain tier

 

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.

  1. What is an identifier?
    An identifier is the name you assign to a class, variable or method.

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.

 

  1. What is a primitive variable?
    A primitive variable is assigned one of the 8 primitive data types and contains data.

 

 

  1. What is a reference variable?
    A reference variable a class name as a data type and points to an instance of that class.

 

  1. What does a getter do?
    A getter method returns the contents of an attribute variable.
  2. What does a setter do?
    A setter method assigns a value to an attribute variable.

 

  1. Explain attribute accessibility.
    When defining attributes you can specify the accessibility of a variable as
    public, private, or protected. The keyword public allows any class to access the variable directly while private prohibits direct access and the variable is accessible only from within the class where it is defined. The keyword protected allows both subclasses and classes within the same package to have direct access. If you omit the accessibility specification, Java uses a default called package access that permits classes within the same package direct access.  If you want to have package access, omit the accessibility specification.

 

  1. Explain method accessibility.
    The accessibility (
    public, private, or protected) for a method is the same as that described earlier for variables.  Generally, you assign public accessibility to methods because you want other objects to invoke them.

 

  1. Distinguish between an argument and a parameter.
    Arguments are passed into parameters.

 

  1. What is a standard method?
    Getters and setters are generally called standard methods.

 

  1. Why do getters generally have an empty parameter list?
    Getter methods do not receive arguments.

 

  1. Why do setters generally have a return data type of void?
    Setters do not return a value.

 

14.     What causes a constructor method to be invoked?
Instantiating a class using the keyword
new.

 

  1. How are constructor methods named?
    They are named the same as their class.

 

  1. What is a default constructor?
    An empty constructor Java uses if you do not write one.

 

  1. What is a parameterized constructor?
    A constructor you write to receive arguments used to populate attributes.