The Papaer Java Test Questions and Answers Essay

1514 Words Apr 7th, 2013 7 Pages
Gaddis – Starting Out With Java 5 – From Control Structures to Objects
Chapter 06 – A First Look At Classes

Multiple Choice

1. One or more objects may be created from a(n)_____.
a. field
b. class
c. method
d. instance

ANS: B

2. Class objects normally have _____ that perform useful operations on their data, but primitive variables do not.
a. fields
b. instances
c. methods
d. relationships

ANS: C

3. In the cookie cutter method: Think of the _____ as a cookie cutter and _____ as the cookies.
a. object; classes
b. class; objects
c. class; fields
d. field; methods

ANS: B

4. A UML diagram does not contain _____.
a. class name
b. methods
c. fields
d. object names

ANS: D

5. An access specifier
…show more content…
Given the following code, what will be the value of finalAmount when it is displayed? public class Order
{
private int orderNum; private double orderAmount; private double orderDiscount; public Order(int orderNumber, double orderAmt, double orderDisc) { orderNum = orderNumber; orderAmount = orderAmt; orderDiscount = orderDisc; }
}
public class CustomerOrder
{
public static void main(String[] args) { int ordNum = 1234; double ordAmount = 580.00; double discountPer = 0.1; Order order; double finalAmount = order.orderAmount – order.orderAmount * order.orderDiscount; System.out.println(“Final order amount = $” + finalAmount); }
}
a. 528.00
b. 580.00
c. There is no value because the constructor has an error.
d. There is no value because the object order has not been created.

ANS: D

21. A class specifies the _____ and _____ that a particular type of object has.
a. relationships; methods
b. fields; object names
c. fields; methods
d. relationships; object names

ANS: C

22. ____ refers to the combining of data and code into a single object.
a. Data hiding
b. Abstraction
c. Object
d. Encapsulation

ANS: D

23. Another term for an object of a class is ____.
a. access specifier
b. instance
c. member
d. method

ANS: B

24. In this book the general layout of a UML diagram is a box that is divided into three sections. The top section has the ____; the middle

Related Documents