Full Test Bank Chapter.2 Using Objects - Big Java Early Objects 5e Complete Test Bank by Cay S. Horstmann. DOCX document preview.

Full Test Bank Chapter.2 Using Objects

Chapter 2: Using Objects Test Bank

Multiple Choice

1. A set of values and the operations that can be carried out with those values are called _______.

A) literals

B) numbers

C) values

D) types

Section Ref: Section 2.1 Objects and Classes

Title: A set of values and the operations that can be carried out with those values are called _______.

Difficulty: Easy

2. What is the name of the type that denotes floating-point numbers that can have fractional parts?

A) double

B) floatingPoint

C) int

D) integer

Section Ref: Section 2.1 Objects and Classes

Title: What is the name of the type that denotes floating-point numbers...

Difficulty: Easy

3. What is the name of the type that denotes whole numbers?

A) double

B) int

C) whole

D) integer

Section Ref: Section 2.1 Objects and Classes

Title: What is the name of the type that denotes whole numbers?

Difficulty: Easy

4. Which is a valid number literal?

A) 1x10^4

B) 1E4

C) 3 1/2

D) 10,000

Section Ref: Section 2.1 Objects and Classes

Title: Which is a valid number literal?

Difficulty: Medium

5. What is the name of the type that denotes a string of characters?

A) Characters

B) char

C) charString

D) String

Section Ref: Section 2.1 Objects and Classes

Title: What is the name of the type that denotes a string of characters?

Difficulty: Easy

6. Which of the following values does not have a primitive type?

A) 12.50

B) "Hello"

C) 6

D) 1E4

Section Ref: Section 2.1 Objects and Classes

Title: Which of the following values does not have a primitive type?

Difficulty: Easy

7. What is a storage location in the computer's memory called that has a type, name, and contents?

A) identifier

B) literal

C) label

D) variable

Section Ref: Section 2.2 Variables

Title: What is a storage location in the computer's memory called that has a type, name, and contents?

Difficulty: Easy

8. Which of the following declares a variable that will store a welcome message?

A) String welcome;

B) double welcome;

C) Char welcome;

D) int welcome;

Section Ref: Section 2.1 Objects and Classes

Title: Which of the following declares a variable that will store a welcome message?

Difficulty: Easy

9. Which of the following declares a variable that will store a measurement with fractional parts?

A) int measure;

B) double measure;

C) String measure;

D) integer measure;

Section Ref: Section 2.1 Objects and Classes

Title: Which of the following declares a variable that will store a measurement with fractional parts?

Difficulty: Easy

10. Which of the following declares a variable that will store a count with an integer value?

A) integer count;

B) double count;

C) String count;

D) int count;

Section Ref: Section 2.1 Objects and Classes

Title: Which of the following declares a variable that will store a count with an integer value?

Difficulty: Easy

11. Which term is used to describe the name of a variable, method, or class?

A) type

B) literal

C) identifier

D) label

Section Ref: Section 2.2 Variables

Title: Which term is used to describe the name of a variable, method, or class?

Difficulty: Easy

12. Which statement about identifiers is correct?

A) Identifiers are not case sensitive.

B) Spaces are permitted inside identifiers.

C) Identifiers can use symbols such as ? or %.

D) Identifiers can be made up of letters, digits, and the underscore (_) character.

Section Ref: Section 2.2 Variables

Title: Which statement about identifiers is correct?

Difficulty: Easy

13. By convention, variables begin with a(n) _____________.

A) uppercase letter

B) digit

C) lowercase letter

D) dollar sign

Section Ref: Section 2.2 Variables

Title: TB 2.12 By convention, variables begin with a(n) _____________.

Difficulty: Easy

14. By convention, classes begin with a(n) _____________.

A) lowercase letter

B) dollar sign

C) digit

D) uppercase letter

Section Ref: Section 2.2 Variables

Title: By convention, classes begin with a(n) _____________.

Difficulty: Easy

15. Which of the following is the best choice for a variable identifier that will store a name?

A) name

B) Name

C) n

D) nm

Section Ref: Section 2.2 Variables

Title: Which of the following is the best choice for a variable identifier that will store a name?

Difficulty: Easy

16. What is the name of the = operator in Java?

A) inequality

B) assignment

C) identity

D) equality

Section Ref: Section 2.3 Calling Methods

Title: What is the name of the = operator in Java?

Difficulty: Easy

17. What is the purpose of the assignment operator?

A) to check for inequality

B) to check for identity

C) to check for equality

D) to change the value of a variable

Section Ref: Section 2.3 Calling Methods

Title: What is the purpose of the assignment operator?

Difficulty: Easy

18. Which statement declares a variable that will store an integer value?

A) integer count;

B) int count;

C) count = 5;

D) String count = 5;

Section Ref: Section 2.3 Calling Methods

Title: Which statement declares a variable that will store an integer value?

Difficulty: Easy

19. Which statement stores an integer value in a variable?

A) count = 5;

B) String count = 5;

C) int count;

D) integer count = 5;

Section Ref: Section 2.3 Calling Methods

Title: Which statement stores an integer value in a variable?

Difficulty: Easy

20. Which statement declares and stores an integer value in a variable?

A) count = 5;

B) int count = 5;

C) integer count = 5;

D) String count = 5;

Section Ref: Section 2.3 Calling Methods

Title: Which statement declares and stores an integer value in a variable?

Difficulty: Easy

21. Assume that the variable count has been declared as type int, which statement changes the value of count?

A) count = 6;

B) count == 6;

C) integer count = 6;

D) count := 6;

Section Ref: Section 2.3 Calling Methods

Title: Which statement changes the value of the variable count?

Difficulty: Easy

22. Assume that the variable count has been declared as type int. Which statement adds 10 to count?

A) count = 10;

B) count == count + 10;

C) count = count + 10;

D) count + 10;

Section Ref: Section 2.3 Calling Methods

Title: Which statement adds 10 to the original value of count?

Difficulty: Easy

23. Which of the following code fragments will cause an error?

A) String greeting = "Hello, Dave!";

B) String greeting = "Hello, World!";

int n = greeting.length();

C) int luckyNumber;

System.out.println(luckyNumber);

D) PrintStream printer = System.out;

Section Ref: Section 2.3 Calling Methods

Title: Which code fragment will cause an error?

Difficulty: Medium

24. What is an object?

A) A sequence of instructions.

B) Any value stored in a variable.

C) An entity in your program that is manipulated by calling methods.

D) Any input to a method.

Section Ref: Section 2.3 Calling Methods

Title: What is an object?

Difficulty: Easy

25. What is the type of an object?

A) variable

B) method

C) reference

D) class

Section Ref: Section 2.3 Calling Methods

Title: What is the type of an object?

Difficulty: Easy

26. "System.out" is an instance of (example of?) which class?

A) String

B) Println

C) System

D) PrintStream

Section Ref: Section 2.3 Calling Methods

Title: The System.out object belongs to which class?

Difficulty: Easy

27. Which of the following statements about objects is correct?

A) An object defines the methods for a class.

B) Every object belongs to a class.

C) An object is a sequence of instructions.

D) All entities, even numbers, are objects.

Section Ref: Section 2.3 Calling Methods

Title: Which of the following statements about objects is correct?

Difficulty: Easy

28. Which of the following statements about methods is correct?

A) A method is a sequence of instructions that could access the data of an object

B) A method name is unique across the entire program.

C) A method can be called on any object in any class.

D) Methods are stored in variables.

Section Ref: : Section 2.3 Calling Methods

Title: Which of the following statements about methods is correct?

Difficulty: Easy

29. Which of the following statements about classes is correct?

A) By convention, class names begin with a lowercase letter.

B) A class declares the methods that you can apply to its objects.

C) All entities, even primitive numbers, are classes.

D) A class is a sequence of instructions that accesses the data of an object.

Section Ref: : Section 2.3 Calling Methods

Title: Which of the following statements about classes is correct?

Difficulty: Easy

30. Which is not a method of the String class?

A) length

B) toUpperCase

C) toLowerCase

D) println

Section Ref: : Section 2.3 Calling Methods

Title: Which is not a method of the String class?

Difficulty: Easy

31. If greeting is a String object, which method call is incorrect?

A) greeting.length()

B) greeting.toLowerCase()

C) greeting.toUpperCase()

D) greeting.println()

Section Ref: Section 2.3 Calling Methods

Title: Which method call is incorrect?

Difficulty: Medium

32. What is the term used to specify the remote control for a class, indicating what you can do with the objects that belong to the class?

A) private interface

B) public interface

C) private implementation

D) hidden implementation

Section Ref: Section 2.3 Calling Methods

Title: What is the term used to specify the remote control for a class?

Difficulty: Easy

33. A method name is ____________________ if a class has more than one method with that name (but different parameter types).

A) overridden

B) overimplemented

C) overwhelmed

D) overloaded

Section Ref: Section 2.3 Calling Methods

Title: A method name is ____________________ if a class has more than one method with that name (but different parameter types).

Difficulty: Easy

34. The input to a method is called a(n) _______________.

A) overloaded

B) parameter

C) interface

D) procedure

Section Ref: Section 2.3 Calling Methods

Title: The input to a method is called a(n) _______________.

Difficulty: Easy

35. The object on which the method call is invoked provides input to the method, and is called a(n) _________________.

A) interface

B) procedure

C) implicit parameter

D) explicit parameter

Section Ref: Section 2.3 Calling Methods

Title: The object on which the method call is invoked is a(n) _________________.

Difficulty: Easy

36. Input to a method enclosed in parentheses after the method name is known as ______________.

A) implicit parameters

B) interfaces

C) explicit parameters

D) return values

Section Ref: Section 2.3 Calling Methods

Title: Input to a method enclosed in parentheses after the method name is known as ______________.

Difficulty: Easy

37. Which method call represents the invocation of a method that does not have explicit parameters?

A) greeting.replace("Hello", "Welcome");

B) greeting.length

C) greeting.length()

D) System.out.println(greeting);

Section Ref: Section 2.3 Calling Methods

Title: Which method call represents the invocation of a method that does not have explicit parameters?

Difficulty: Easy

38. The output of a method is called its __________ value.

A) implicit

B) explicit

C) parameter

D) return

Section Ref: Section 2.3 Calling Methods

Title: The output of a method is called its __________ value.

Difficulty: Easy

39. Which of the following statements about methods is correct?

A) A method can have only one explicit parameter.

B) The return value of a method can be used as a parameter.

C) Every method must have a return value.

D) A method can have multiple implicit parameters.

Section Ref: Section 2.3 Calling Methods

Title: Which of the following statements about methods is correct?

Difficulty: Medium

40. Which of the following method calls illustrates the return value of a method as a parameter?

A) greeting.length();

B) greeting.println("Hello");

C) System.out.println(length.greeting());

D) System.out.println(greeting.length());

Section Ref: Section 2.3 Calling Methods

Title: Which of the following method calls illustrates the return value of a method as a parameter?

Difficulty: Medium

41. If greeting refers to a String object, which of the following is a syntactically correct Java statement?

A) System.out.println(length().greeting);

B) System.out.println(greeting());

C) System.out.println(greeting.length());

D) greeting.println("Hello");

Section Ref: Section 2.3 Calling Methods

Title: Which of the following is a syntactically correct Java statement?

Difficulty: Medium

42. What is the declared return type for a method that does not have a return value?

A) String

B) There is no declared return type when a method does not return a value.

C) void

D) A method must return a value.

Section Ref: Section 2.3 Calling Methods

Title: What is the declared return type for a method that does not have a return value?

Difficulty: Easy

43. Which of the following represents a method declaration with a void return type?

A) public void setValue(int value) { ... }

B) public void int getValue() { ... }

C) void public setValue(int value) { ... }

D) void int getValue() { ... }

Section Ref: Section 2.3 Calling Methods

Title: Which of the following represents a method declaration with a void return type?

Difficulty: Easy

44. Which of the following represents a method call to a method with a void return type?

A) greeting.isEmpty()

B) System.out.println()

C) greeting.replace("Hello","World")

D) greeting.length()

Section Ref: Section 2.3 Calling Methods

Title: Which of the following represents a method call to a method with a void return type?

Difficulty: Easy

45. Which operator constructs object instances?

A) new

B) instanceof

C) void

D) construct

Section Ref: Section 2.4 Constructing Objects

Title: Which operator constructs object instances?

Difficulty: Easy

46. Which of the following constructs a Circle of radius 3, assuming the construction parameter is the radius value?

A) Circle(3).new

B) new Circle(3)

C) new.Circle(3)

D) Circle(3)

Section Ref: Section 2.4 Constructing Objects

Title: Which of the following constructs a Circle of radius 3?

Difficulty: Easy

47. Which statement declares a variable that references a Circle of radius 3?

A) Circle c = Circle(3)

B) Circle c = new Circle(3);

C) Circle c.new.Circle(3);

D) c.Circle(3);

Section Ref: Section 2.4 Constructing Objects

Title: Which statement declares a variable that references a Circle of radius 3?

Difficulty: Easy

48. Which statement calls a constructor with no construction parameters?

A) Circle c = new Circle();

B) A call to a constructor must have construction parameters.

C) Circle c = new Circle;

D) Circle c = Circle()

Section Ref: Section 2.4 Constructing Objects

Title: Which statement calls a constructor with no construction parameters?

Difficulty: Easy

49. What terminology describes a method that returns information about its implicit parameter and does not change the parameter's internal data?

A) mutator

B) accessor

C) void

D) public

Section Ref: Section 2.5 Accessor and Mutator Methods

Title: What terminology describes a method that returns information about its implicit parameter and does not change the parameter's internal data?

Difficulty: Easy

50. What terminology describes a method that modifies the internal data of its implicit parameter?

A) public

B) void

C) mutator

D) accessor

Section Ref: Section 2.5 Accessor and Mutator Methods

Title: What terminology describes a method that modifies the internal data of its implicit parameter?

Difficulty: Easy

51. Which of the following is a mutator method for the Rectangle class?

A) getHeight

B) translate

C) getWidth

D) isEmpty

Section Ref: Section 2.5 Accessor and Mutator Methods

Title: Which of the following is a mutator method?

Difficulty: Easy

52. What does API stand for?

A) Applet Programming Interface

B) Application Programmer Interaction

C) Application Programming Instance

D) Application Programming Interface

Section Ref: Section 2.6 The API Documentation

Title: What does API stand for?

Difficulty: Easy

53. A _____________ is a collection of classes with a related purpose.

A) package

B) import

C) method

D) collection

Section Ref: Section 2.6 The API Documentation

Title: What is a collection of classes with a related purpose?

Difficulty: Easy

54. To use a class in another package you need to ________ it.

A) export

B) overload

C) rewrite

D) import

Section Ref: Section 2.6 The API Documentation

Title: To use a class in another package you need to ________ it.

Difficulty: Easy

55. Which package is automatically imported in any Java program?

A) java.system

B) java.lang

C) java.language

D) java.util

Section Ref: Section 2.6 The API Documentation

Title: Which package is automatically imported in any Java program?

Difficulty: Medium

56. Which class is part of the java.lang package?

A) Rectangle

B) PrintStream

C) String

D) Circle

Section Ref: Section 2.6 The API Documentation

Title: Which class is part of the java.lang package?

Difficulty: Medium

57. Which import statement allows for the use of the Rectangle class?

A) import java.geom.Rectangle2D;

B) import java.geom.Rectangle;

C) import java.geom.RectangularShape;

D) import java.awt.Rectangle;

Section Ref: Section 2.6 The API Documentation

Title: Which import statement allows for the use of the Rectangle class?

Difficulty: Medium

58. Which method checks whether a point lies within the rectangle?

A) add

B) getBounds

C) translate

D) contains

Section Ref: Section 2.6 The API Documentation

Title: Which method checks whether a point lies within the rectangle?

Difficulty: Medium

59. Which method would you use to obtain the string "1234567890" from the string "123-456-7890"?

A) isEmpty

B) replace

C) trim

D) length

Section Ref: Section 2.6 The API Documentation

Title: Find a method in the API documentation for the String class.

Difficulty: Medium

60. Which of the following statements about test programs is true?

A) Test programs verify that methods have been implemented correctly.

B) A tester class does not contain the main method.

C) You do not have to display the expected results.

D) Writing test programs is not an important skill.

Section Ref: Section 2.7 Implementing a Test Program

Title: Which of the following statements about test programs is true?

Difficulty: Easy

61. Which of the following terms denotes the memory location of an object?

A) implicit parameter

B) mutator method

C) encapsulation

D) object reference

Section Ref: Section 2.8 Object References

Title: Which of the following terms denotes the memory location of an object?

Difficulty: Easy

62. What do object variables store?

A) objects

B) classes

C) references

D) numbers

Section Ref: Section 2.8 Object References

Title: What do object variables store?

Difficulty: Easy

63. Assuming the following Java statement:

Circle c1 = new Circle(3);

What does the variable c1 store?

A) The constructed object itself.

B) A reference to the Circle class.

C) A reference to the memory location of the constructed object.

D) The numeric value 3.

Section Ref: Section 2.8 Object References

Title: What does the variable c1 of type Circle store?

Difficulty: Medium

64. Assuming the following Java statement:

int num = 10;

What does the variable num store?

A) A reference to the memory location where the value 10 is stored.

B) A reference to the int primitive type.

C) An object representing the number 10.

D) The numeric value 10.

Section Ref: Section 2.8 Object References

Title: What does the variable num of type int store?

Difficulty: Medium

65. What is the output of the following code:

Circle c1 = new Circle(3);

Circle c2 = c1;

c1.setRadius(4);

System.out.println(c2.getRadius());

A) 4

B) 3

C) 6

D) 8

Section Ref: Section 2.8 Object References

Title: What is the output of the following code?

Difficulty: Medium

66. What is the output of the following code:

Circle c1 = new Circle(3);

Circle c2 = new Circle(3);

c1.setRadius(4);

System.out.println(c2.getRadius());

A) 3

B) 8

C) 6

D) 4

Section Ref: Section 2.8 Object References

Title: What is the output of the following code?

Difficulty: Medium

67. What is the output of the following code:

int num1 = 6;

int num2 = num1;

num2 = num2 + 10;

System.out.println(num1);

A) 6

B) 10

C) 4

D) 16

Section Ref: Section 2.8 Object References

Title: What is the output of the following code?

Difficulty: Medium

68. What is the output of the following code:

int num1 = 6;

int num2 = 10;

num1 = num2;

num2 = num1;

System.out.println(num1 + ", " + num2);

A) 6, 10

B) 10, 6

C) 6, 6

D) 10, 10

Section Ref: Section 2.8 Object References

Title: What is the output of the following code?

Difficulty: Medium

69. What is the output of the following code:

int num1 = 6;

int num2 = 10;

num1 = num1 + num2;

num2 = num1 + num2;

System.out.println(num1 + ", " + num2);

A) 6, 10

B) 16, 16

C) 16, 22

D) 16, 26

Section Ref: Section 2.8 Object References

Title: What is the output of the following code?

Difficulty: Medium

70. Complete this code fragment to ensure that the frame is shown:

JFrame frame = new JFrame();

A) frame.setVisible(true);

B) frame.visible = true;

C) JFrame.setVisible();

D) frame.setVisible();

Section Ref: Section 2.9 Graphical Applications

Title: Complete code fragment to ensure that frame is shown.

Difficulty: Medium

71. Based on the following code, which of the following statements sets the frame to a width of 400 and a height of 200:

final int FRAME_WIDTH = 400;

final int FRAME_HEIGHT = 200;

JFrame frame = new JFrame();

A) frame.size = (FRAME_WIDTH, FRAME_HEIGHT);

B) frame.addSize(FRAME_WIDTH, FRAME_HEIGHT);

C) frame.setSize(FRAME_WIDTH, FRAME_HEIGHT);

D) frame.setSize(FRAME_HEIGHT, FRAME_WIDTH);

Section Ref: Section 2.9 Graphical Applications

Title: Write a statement to set the frame size.

Difficulty: Easy

72. Based on the following statement, which of the following statements sets the title of the frame:

JFrame frame = new JFrame();

A) frame.title = "An Empty Frame";

B) frame.setTitle(JFrame.EMPTY);

C) frame.addTitle("An Empty Frame");

D) frame.setTitle("An Empty Frame");

Section Ref: Section 2.9 Graphical Applications

Title: Which statement sets the frame title?

Difficulty: Easy

73. What is the nickname for the graphical user interface library in Java?

A) Applet

B) GUI

C) JComponent

D) Swing

Section Ref: Section 2.9 Graphical Applications

Title: What is the nickname for the GUI library in Java?

Difficulty: Medium

74. Place drawing instructions inside the __________ method, which is called whenever the component needs to be repainted.

A) paintComponent

B) draw

C) paint

D) drawComponent

Section Ref: Section 2.9 Graphical Applications

Title: Place drawing instructions inside the ________ method.

Difficulty: Medium

75. Complete the following statement, which constructs an ellipse.

Ellipse2D.Double ellipse =

new ____________________ (x, y, width, height);

A) Double.Ellipse2D

B) Ellipse2D.Double

C) Ellipse2D

D) Double

Section Ref: Section 2.10 Ellipses, Lines, Text, and Color

Title: Complete the statement that constructs an ellipse.

Difficulty: Easy

76. In the code below, write a statement that sets the graphic to green.

public class ItalianFlagComponent extends JComponent

{

public void paintComponent(Graphics g)

{

Graphics2D g2 = (Graphics2D) g;

Rectangle.Double leftRectangle = new Rectangle.Double(100, 100, 30, 60);

. . .

____

. . .

}

}

A) g2.setColor(GREEN);

B) g2.SetColor(0, 255, 0);

C) g2.setColor(Color.GREEN);

D) g2.setColor("GREEN");

Section Ref: Section 2.10 Ellipses, Lines, Text, and Color

Title: Which call sets the graphics color to green?

Difficulty: Easy

Document Information

Document Type:
DOCX
Chapter Number:
2
Created Date:
Aug 21, 2025
Chapter Name:
Chapter 2 Using Objects
Author:
Cay S. Horstmann

Connected Book

Big Java Early Objects 5e Complete Test Bank

By Cay S. Horstmann

Test Bank General
View Product →

$24.99

100% satisfaction guarantee

Buy Full Test Bank

Benefits

Immediately available after payment
Answers are available after payment
ZIP file includes all related files
Files are in Word format (DOCX)
Check the description to see the contents of each ZIP file
We do not share your information with any third party