100% found this document useful (1 vote)
12 views

Starting Out with Java From Control Structures through Objects 5th Edition Tony Gaddis Test Bank instant download

The document provides links to various test banks and solutions manuals for textbooks authored by Tony Gaddis, including titles on Java and C++. It features multiple-choice questions and answers related to Java programming concepts, such as classes, objects, methods, and UML diagrams. The content is aimed at assisting students in understanding object-oriented programming principles.

Uploaded by

ruhan4dubejkg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
12 views

Starting Out with Java From Control Structures through Objects 5th Edition Tony Gaddis Test Bank instant download

The document provides links to various test banks and solutions manuals for textbooks authored by Tony Gaddis, including titles on Java and C++. It features multiple-choice questions and answers related to Java programming concepts, such as classes, objects, methods, and UML diagrams. The content is aimed at assisting students in understanding object-oriented programming principles.

Uploaded by

ruhan4dubejkg
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 18

Starting Out with Java From Control Structures

through Objects 5th Edition Tony Gaddis Test


Bank pdf download

https://testbankdeal.com/product/starting-out-with-java-from-
control-structures-through-objects-5th-edition-tony-gaddis-test-
bank/

Download more testbank from https://testbankdeal.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Starting Out with Java From Control Structures through


Objects 5th Edition Tony Gaddis Solutions Manual

https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-objects-5th-edition-tony-gaddis-solutions-manual/

testbankdeal.com

Starting Out With C++ From Control Structures Through


Objects 7th Edition Tony Gaddis Test Bank

https://testbankdeal.com/product/starting-out-with-c-from-control-
structures-through-objects-7th-edition-tony-gaddis-test-bank/

testbankdeal.com

Starting Out with Java From Control Structures through


Objects 6th Edition Gaddis Test Bank

https://testbankdeal.com/product/starting-out-with-java-from-control-
structures-through-objects-6th-edition-gaddis-test-bank/

testbankdeal.com

Organizational Behavior A Practical Problem Solving


Approach 1st Edition Kinicki Test Bank

https://testbankdeal.com/product/organizational-behavior-a-practical-
problem-solving-approach-1st-edition-kinicki-test-bank/

testbankdeal.com
Intercultural Communication Globalization and Social
Justice 2nd Edition Sorrells Solutions Manual

https://testbankdeal.com/product/intercultural-communication-
globalization-and-social-justice-2nd-edition-sorrells-solutions-
manual/
testbankdeal.com

Public Health Science Nursing Practice 1st Edition Savage


Test Bank

https://testbankdeal.com/product/public-health-science-nursing-
practice-1st-edition-savage-test-bank/

testbankdeal.com

Short Term Financial Management 3rd Edition Maness Test


Bank

https://testbankdeal.com/product/short-term-financial-management-3rd-
edition-maness-test-bank/

testbankdeal.com

Intermediate Accounting Reporting And Analysis 2017 Update


2nd Edition Wahlen Test Bank

https://testbankdeal.com/product/intermediate-accounting-reporting-
and-analysis-2017-update-2nd-edition-wahlen-test-bank/

testbankdeal.com

Introduction to Geospatial Technologies 1st Edition


Shellito Test Bank

https://testbankdeal.com/product/introduction-to-geospatial-
technologies-1st-edition-shellito-test-bank/

testbankdeal.com
Business Communication Essentials 7th Edition Bovee
Solutions Manual

https://testbankdeal.com/product/business-communication-
essentials-7th-edition-bovee-solutions-manual/

testbankdeal.com
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

Chapter 6

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 metaphor, think of the ________ as a cookie cutter and ________ as the cookies.
a. object; classes
b. class; objects
c. class; fields
d. attribute; methods

ANS: B

4. Which of the following are classes from the Java API?


a. Scanner
b. Random
c. PrintWriter
d. All of the above

ANS: D

5. 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

ANS: A

6. What is stored by a reference variable?


a. A binary encoded decimal
b. A memory address
c. An object
d. A string
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

ANS: B

7. Most programming languages that are in use today are:


a. procedural
b. logic
c. object-oriented
d. functional

ANS: C

8. 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

ANS: B

9. A UML diagram does not contain:


a. the class name.
b. the method names.
c. the field names.
d. object names

ANS: D

10. 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

ANS: D

11. For the following code, which statement is not true?

public class Sphere


{
private double radius;
public double x;
private double y;
private double z;
}

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, y, and z are called members of the Circle class.
d. z is available to code that is written outside the Circle class.
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

ANS: D

12. You should not define a class field that is dependent upon the values of other class fields:
a. in order to avoid having stale data
b. because it is redundant
c. because it should be defined in another class
d. in order to keep it current

ANS: A

13. What does the following UML diagram entry mean?

+ setHeight(h : double) : void

a. this is a public attribute named Height and is a double data type


b. this is a private method with no parameters and returns a double data type
c. this is a private attribute named Height and is a double data type
d. this is a public method with a parameter of data type double and does not return a value

ANS: D

14. Methods that operate on an object's fields are called:


a. instance variables
b. instance methods
c. public methods
d. private methods

ANS: B

15. The scope of a private instance field is:


a. the instance methods of the same class
b. inside the class, but not inside any method
c. inside the parentheses of a method header
d. the method in which they are defined

ANS: A

16. 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

ANS: C

17. 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";
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

ANS: A

18. 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

ANS: B

19. 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.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.
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

ANS: D

20. 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

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

ANS: D

22. Another term for an object of a class is


a. access specifier
b. instance
c. member
d. method

ANS: B

23. 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

ANS: A

24. 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.

ANS: D

25. It is common practice in object-oriented programming to make all of a class's


Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

a. methods private
b. fields private
c. fields public
d. fields and methods public

ANS: B

26. After the header, the body of the method appears inside a set of:
a. brackets, []
b. parentheses, ()
c. braces, {}
d. double quotes, ""

ANS: C

27. In UML diagrams, this symbol indicates that a member is private:


a. *
b. #
c. -
d. +

ANS: C

28. In UML diagrams, this symbol indicates that a member is public.

a. /
b. @
c. -
d. +

ANS: D

29. In a UML diagram to indicate the data type of a variable enter:


a. the variable name followed by the data type
b. the variable name followed by a colon and the data type
c. the class name followed by the variable name followed by the data type
d. the data type followed by the variable name

ANS: B

30. 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

ANS: A

31. 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
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

c. the values for each field


d. the method names

ANS: B

32. 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.

ANS: D

33. 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

ANS: D

34. 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

ANS: C

35. 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

ANS: C

36. 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)
{
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

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.println("Final order amount = $" +
finalAmount);
}
}
a. 528.00
b. 580.00
c. 522.00
d. There is no value because the object order has not been created.

ANS: C

37. A class’s responsibilities include:

a. the things a class is responsible for doing c. both A and B


b. the things a class is responsible for knowing d. neither A or B

ANS: C

38. Instance methods do not have this key word in their headers:
a. public
b. static
c. private
d. protected

ANS: B

39. Which of the following is not involved in finding the classes when developing an object-oriented application?

a. Describe the problem domain. c. Write the code.


b. Identify all the nouns. d. Refine the list of nouns to include only those
that are relevant to the problem.
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

ANS: C

40. This is a group of related classes.

a. archive c. collection
b. package d. attachment

ANS: B

41. Quite often you have to use this statement to make a group of classes available to a program.

a. import c. link
b. use d. assume

ANS: A

42. Look at the following statement.

import java.util.Scanner;

This is an example of

a. a wildcard import c. unconditional import


b. an explicit import d. conditional import

ANS: B

43. Look at the following statement.

import java.util.*;

This is an example of:

a. a wildcard import c. unconditional import


b. an explicit import d. conditional import

ANS: A

44. The following package is automatically imported into all Java programs.

a. java.java c. java.util
b. java.default d. java.lang

ANS: D

TRUE/FALSE

1. An object can store data.

ANS: T
Gaddis: Starting Out with Java: From Control Structures through Objects, 5/e © 2012 Pearson Education

2. A class in not an object, but a description of an object.

ANS: T

3. An access specifier indicates how the class may be accessed.

ANS: T

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.

ANS: T

5. Instance methods should be declared static.

ANS: F

6. A constructor is a method that is automatically called when an object is created.

ANS: T

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

ANS: T

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

ANS: F

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

ANS: F

10. Instance methods do not have the key word static in their headers.

ANS: T

11. The term "default constructor" is applied to the first constructor written by the author of a class.

ANS: 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.

ANS: F

13. The term "no-arg constructor" is applied to any constructor that does not accept arguments.

ANS: T

14. The java.lang package is automatically imported into all Java programs.

ANS: T
Another Random Scribd Document
with Unrelated Content
back
back

You might also like