Docsity

ABSOLUTE JAVA 6TH EDITION COMPREHENSIVE STUDY GUIDE WITH QUESTIONS AND ANSWERS, Exams of Java Programming

Toggle sidebar
bg1
ABSOLUTE JAVA 6TH EDITION COMPREHENSIVE STUDY GUIDE
WITH QUESTIONS AND ANSWERS
Question 1.
Class objects normally have ________ that perform useful operations on their data, but
primitive variables do not.
A) fields
B) instances
C) methods
D) relationships.
Answer: Answer: C
Question 2.
In the cookie cutter metaphor, think of the ________ as a cookie cutter and ________ as
the cookies.
A) object; classes
B) class; objects
C) class; fields
D) attribute; methods.
Answer: Answer: B
Question 3.
Which of the following are classes from the Java API?
A) Scanner
B) Random
C) PrintWriter
D) All of the above.
Answer: Answer: D
Question 4.
When you are working with a ________, you are using a storage location that holds a
piece of data.
A) primitive variable
B) reference variable
C) numeric literal
D) binary number.
Answer: Answer: A
pf3
pf4
pf5
pf8
pf9
pfa

Partial preview of the text

Download ABSOLUTE JAVA 6TH EDITION COMPREHENSIVE STUDY GUIDE WITH QUESTIONS AND ANSWERS and more Exams Java Programming in PDF only on Docsity!

ABSOLUTE JAVA 6TH EDITION COMPREHENSIVE STUDY GUIDE

WITH QUESTIONS AND ANSWERS

Question 1.

Class objects normally have ________ that perform useful operations on their data, but primitive variables do not. A) fields B) instances C) methods D) relationships.

Answer: Answer: C

Question 2.

In the cookie cutter metaphor, think of the ________ as a cookie cutter and ________ as the cookies. A) object; classes B) class; objects C) class; fields D) attribute; methods.

Answer: Answer: B

Question 3.

Which of the following are classes from the Java API? A) Scanner B) Random C) PrintWriter D) All of the above.

Answer: Answer: D

Question 4.

When you are working with a ________, you are using a storage location that holds a piece of data. A) primitive variable B) reference variable C) numeric literal D) binary number.

Answer: Answer: A

What is stored by a reference variable? A) A binary encoded decimal B) A memory address C) An object D) A string.

Answer: Answer: B

Question 6.

Most programming languages that are in use today are: A) procedural B) logic C) object-oriented D) functional.

Answer: Answer: C

Question 7.

Java allows you to create objects of this class in the same way you would create primitive variables. A) Random B) String C) PrintWriter D) Scanner.

Answer: Answer: B

Question 8.

A UML diagram does not contain: A) the class name B) the method names C) the field names D) object names.

Answer: Answer: D

Question 9.

Data hiding, which means that critical data stored inside the object is protected from code outside the object, is accomplished in Java by: A) using the public access specifier on the class methods B) using the private access specifier on the class methods C) using the private access specifier on the class definition D) using the private access specifier on the class fields.

Answer: Answer: D

A constructor: A) always accepts two arguments B) has return type of void C) has the same name as the class D) always has an access specifier of private.

Answer: Answer: C

Question 16.

Which of the following statements will create a reference, str, to the String, "Hello, World"? A) String str = "Hello, World"; B) string str = "Hello, World"; C) String str = new "Hello, World"; D) str = "Hello, World";.

Answer: Answer: A

Question 17.

Two or more methods in a class may have the same name as long as: A) they have different return types B) they have different parameter lists C) they have different return types, but the same parameter list D) you cannot have two methods with the same name.

Answer: Answer: B

Question 18.

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 int getOrderAmount() { return orderAmount; } public int getOrderDisc() { return orderDisc; } } public class CustomerOrder { public static void main(String[] args) { int ordNum = 1234; double ordAmount = 580.00; double discountPer = .1; Order order; double finalAmount = order.getOrderAmount() — order.getOrderAmount() * order.getOrderDisc(); System.out.printf("Final order amount = $%,.2f\n", finalAmount); } } A) 528. B) 580. C) There is no value because the constructor has an error. D) There is no value because the object order has not been created..

Answer: Answer: D

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.

Answer: Answer: C

Question 20.

This refers to the combining of data and code into a single object. A) Data hiding B) Abstraction C) Object D) Encapsulation.

Answer: Answer: D

Question 21.

Another term for an object of a class is: A) access specifier B) instance C) member D) method.

Answer: Answer: B

Question 22.

In your textbook the general layout of a UML diagram is a box that is divided into three sections. The top section has the ________; the middle section holds ________; the bottom section holds ________. A) class name; attributes or fields; methods B) class name; object name; methods C) object name; attributes or fields; methods D) object name; methods; attributes or fields.

Answer: Answer: A

Question 23.

For the following code, which statement is NOT true? public class Circle { private double radius; public double x; private double y; } A) x is available to code that is written outside the Circle class. B) radius is not available to code written outside the Circle class. C) radius, x, and y are called members of the Circle class. D) y is available to code that is written outside the Circle class..

Answer: Answer: D

When an object is created, the attributes associated with the object are called: A) instance fields B) instance methods C) fixed attributes D) class instances.

Answer: Answer: A

Question 30.

When an object is passed as an argument to a method, what is passed into the method's parameter variable? A) the class name B) the object's memory address C) the values for each field D) the method names.

Answer: Answer: B

Question 31.

A constructor is a method that: A) returns an object of the class. B) never receives any arguments. C) with the name ClassName.constructor. D) performs initialization or setup operations..

Answer: Answer: D

Question 32.

The scope of a public instance field is: A) only the class in which it is defined B) inside the class, but not inside any method C) inside the parentheses of a method header D) the instance methods and methods outside the class.

Answer: Answer: D

Question 33.

Which of the following statements will create a reference, str, to the string, "Hello, world"? (1) String str = new String("Hello, world"); (2) String str = "Hello, world"; A) 1 B) 2 C) 1 and 2 D) neither 1 or 2.

Answer: Answer: C

Overloading means multiple methods in the same class: A) have the same name, but different return types B) have different names, but the same parameter list C) have the same name, but different parameter lists D) perform the same function.

Answer: Answer: C

Question 35.

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 double finalOrderTotal() { return orderAmount - orderAmount * orderDiscount; } } public class CustomerOrder { public static void main(String[] args) { Order order; int orderNumber = 1234; double orderAmt = 580.00; double orderDisc = .1; order = new Order(orderNumber, orderAmt, orderDisc); double finalAmount = order.finalOrderTotal(); System.out.printf("Final order amount = $%,.2f\n", finalAmount); } } A) 528. B) 580. C) 522. D) There is no value because the object order has not been created..

Answer: Answer: C

Question 36.

A class's responsibilities include: A) the things a class is responsible for doing B) the things a class is responsible for knowing C) both A and B D) neither A nor B.

Answer: Answer: C

Question 37.

Instance methods do not have this key word in their headers: A) public B) static C) private D) protected.

Answer: Answer: B

The following package is automatically imported into all Java programs. A) java.java B) java.default C) java.util D) java.lang.

Answer: Answer: D

Question 44.

T/F: 1) An object can store data..

Answer: Answer: TRUE

Question 45.

T/F: 2) A class in not an object, but a description of an object..

Answer: Answer: TRUE

Question 46.

T/F: 3) An access specifier indicates how the class may be accessed..

Answer: Answer: TRUE

Question 47.

T/F: 4) A method that stores a value in a class's field or in some other way changes the value of a field is known as a mutator method..

Answer: Answer: TRUE

Question 48.

T/F: 5) Instance methods should be declared static..

Answer: Answer: FALSE

Question 49.

T/F: 6) A constructor is a method that is automatically called when an object is created..

Answer: Answer: TRUE

Question 50.

T/F: 7) Shadowing is the term used to describe where the field name is hidden by the name of a local or parameter variable..

Answer: Answer: TRUE

T/F: 8) The public access specifier for a field indicates that the attribute may not be accessed by statements outside the class..

Answer: Answer: FALSE

Question 52.

T/F: 9) A method that gets a value from a class's field but does not change it is known as a mutator method..

Answer: Answer: FALSE

Question 53.

T/F: 10) Instance methods do not have the key word static in their headers.

Answer: Answer: TRUE

Question 54.

T/F: 11) The term "default constructor" is applied to the first constructor written by the author of a class..

Answer: Answer: FALSE

Question 55.

T/F: 12) When a local variable in an instance method has the same name as an instance field, the instance field hides the local variable..

Answer: Answer: FALSE

Question 56.

T/F: 13) The term "no-arg constructor" is applied to any constructor that does not accept arguments..

Answer: Answer: TRUE

Question 57.

T/F: 14) The java.lang package is automatically imported into all Java programs..

Answer: Answer: TRUE