Name: 
 

lesson567



True/False
Indicate whether the sentence or statement is true or false.
 

1. 

When a Java program is executing, the computer's memory must hold all class templates in their compiled form, variables that refer to objects, and objects as needed.
 

2. 

The identity of an object is simply the variable that references the object.
 

3. 

A class's implementation details can be changed radically without affecting any of its clients provided its interface remains the same.
 

4. 

In Java it is illegal to have two variables referencing the same object.
 

5. 

The keyword public indicates that the class is accessible to all potential clients.
 

6. 

Constructors do not have return types, but all other methods do.
 

7. 

A class can include only one constructor.
 

8. 

A method can only have one return statement.
 

9. 

Variables declared within any compound statement enclosed in braces are said to have local scope.
 

10. 

Global variables can be reused within several different methods without causing a conflict.
 

11. 

A good way to provide temporary storage is to use global variables.
 

12. 

When using turtle graphics, the color of a pen cannot be changed.
 

13. 

The OR operand evaluates to false if one operand is false.
 

14. 

At a minimum, test data should try to achieve complete code coverage, which means every line of code should be executed at least once.
 

15. 

Test data at the limits of validity are called boundary conditions.
 

16. 

Nested if statements offer an alternative to deal with a programs logical complexity.
 

17. 

It is better to write code and then create a flow chart or truth table to verify the code.
 

18. 

One of the most common mistakes in nested if statements involves misplaced braces.
 

19. 

Changing the indentation of if and else statements changes the logic of the code.
 

20. 

Since overusing braces clutters the code, only use braces when needed.
 

21. 

Arithmetic overflow results when the range of a given number is exceeded.
 

22. 

Java uses complete evaluation, in which all parts of a Boolean expression are always evaluated.
 

23. 

Complete code coverage in testing will test all logical paths through a program.
 

24. 

The following nested if statements are equivalent:

if ( it is 3:00 )                  if ( it is 3:00 )
  if ( it is Monday )              if ( it is Monday ){
     go home                      go home     
     go to the gym                go to the gym
                                                  }
 

25. 

If braces are removed from a nested if/else statement, Java pairs the else with the closest preceding if.
 

26. 

The structures of a Graphical User Interface (GUI) programs and a terminal-based programs do not differ.
 

27. 

Developing GUI's in Java is usually not complicated.
 

28. 

A double field object displays text in a window.
 

29. 

A button object activates a method when clicked by a user.
 

30. 

A text area is a convenient device for popping up messages outside an application's main window.
 

31. 

A character literal is enclosed within double quotes.
 

32. 

The readChar method in the KeyboradReader class will only read the first character entered on a line.
 

33. 

The grid of a window object will automatically adjust itself to the needed number of rows and columns.
 

34. 

The 4th parameter in an add method specifies the width of the object.
 

35. 

A programmer cannot set the height and width of a message box.
 

Multiple Choice
Identify the letter of the choice that best completes the statement or answers the question.
 

36. 

The process of creating a new object is called:
a.
encapsulation
c.
instantiation
b.
class
d.
new
 

37. 

Java deletes objects from memory in a process called:
a.
deletion
c.
memory allocation
b.
garbage collection
d.
memory dumping
 

38. 

Which characteristic of an object says that at any moment its instance variables have particular values.
a.
state
c.
identity
b.
behavior
d.
instantiation
 

39. 

What is the list of the methods supported by the server referred to as?
a.
encapsulation
c.
behavior
b.
state
d.
interface
 

40. 

Messages that change an object's state are called:
a.
accessors
c.
mutators
b.
constructors
d.
methods
 

41. 

What is the name of a method that indicates how to initialize a new object?
a.
initializer
c.
mutator
b.
constructor
d.
accessor
 

42. 

If class A extends class B, class B is the _________ of class A.
a.
parent
c.
nephew
b.
child
d.
subclass
 

43. 

If a class A omits the extends <some class> clause, which class is assumed to be the superclass of class A.
a.
Object
c.
System
b.
KeyboardReader
d.
Math
 

44. 

What are activated when the keyword new is used and at no other time.
a.
accessors
c.
constructors
b.
mutators
d.
methods
 

45. 

A method whose implementing code is omitted is called a:
a.
accessor
c.
helper
b.
mutator
d.
stub
 

46. 

Values passed to a method when it is invoked are called:
a.
actual parameters
c.
constructors
b.
formal parameters
d.
initial values
 

47. 

To provide temporary working storage for data in a method a programmer can declare:
a.
global variables
c.
instance variables
b.
local variables
d.
classes
 

48. 

The ________ of a variable is that region of the program within which it can validly appear in lines of code.
a.
lifetime
c.
value
b.
type
d.
scope
 

49. 

Variables defined as instance variables of a class are referred to as:
a.
local
c.
temporary
b.
global
d.
public
 

50. 

The _________ of a variable is the period during which it can be used.
a.
time period
c.
lifetime
b.
scope
d.
type
 

51. 

Which of the following is NOT one of the 3 logical operators introduced in this chapter.
a.
AND
c.
NOT
b.
OR
d.
XOR
 

52. 

If the operator AND is used, which of the following will make the whole condition true?
a.
first operand true, second operand false
c.
both operands true
b.
first operand false, second operand true
d.
both operands false
 

53. 

What is the precedence of the logical operator OR ( || )?
a.
5
c.
3
b.
6
d.
9
 

54. 

Which of the following is the Java symbol for logical AND?
a.
&&
c.
==
b.
!
d.
||
 

55. 

The sets of test data that exercise a program in the same manner are said to belong to the same:
a.
code coverage
c.
equivalence class
b.
set
d.
boundary condition
 

56. 

It is common for programs to fail around which points?
a.
boundary condition points
c.
equivalence class points
b.
extreme condition points
d.
no points
 

57. 

Reformatting the first if/else statement into the second is called:
  ( 1 )                                  ( 2 )
if( )                                     if( )
   statement                            statement
else                                     else if ()
  if( )                                      statement
    statement
a.
extended if statement
c.
two-way if statement
b.
one-way if statement
d.
many-way if statement
 

58. 

A program that tolerates errors in user inputs and recovers gracefully is:
a.
combinatorial
c.
clear
b.
robust
d.
solid
 

59. 

When a program attempts to add one to the most positive integer in the range what value is yielded.
a.
0
c.
null
b.
the most negative integer
d.
a random integer
 

60. 

In general, how many combinations of true and false are there for n operands in a truth table.
a.
2n
c.
2n
b.
n
d.
4n
 

61. 

What is the symbol for the NOT operator in Java?
a.
!
c.
<>
b.
~
d.
N
 

62. 

Which of the following Boolean expressions is equivalent to: !( p && q )
a.
!p && !q
c.
p && !q
b.
!p && q
d.
!p || !q
 

63. 

The approach in which evaluation of a Boolean expression stop as soon as possible is called:
a.
truth evaluation
c.
complete evaluation
b.
short-circuit evaluation
d.
ASAP-evaluation
 

64. 

What is used in Java to determine if two string objects contain equal strings.
a.
==
c.
equals( )
b.
compare( )
d.
isEqual( )
 

65. 

An Artificial Intelligence program that learns a set of rules is called a:
a.
softbot
c.
smart program
b.
robot
d.
neural net
 

66. 

A GUI program is ________, meaning that it is inactive until the user clicks a button or selects a menu option.
a.
prompt driven
c.
user friendly
b.
robust
d.
event driven
 

67. 

What type of input technique asks the user if there are more inputs are each set of inputs?
a.
count-controlled
c.
sentinel-controlled
b.
query-controlled
d.
user-controlled
 

68. 

What is Java's standard GUI-building toolkit?
a.
AWT
c.
Swing
b.
Motif
d.
MFC
 

69. 

A GUI program must be a subclass of which class?
a.
Frame
c.
JButton
b.
JLabel
d.
GBFrame
 

70. 

A ________ object can accept user input and/or display program output.
a.
button
c.
button
b.
double field
d.
GBFrame
 

71. 

What does the addLabel() method NOT do?
a.
activate methods
c.
position a label object
b.
initialize a label object
d.
instantiate a label object
 

72. 

The getNumber and _________ methods read and write numbers from and to numeric fields, respectively.
a.
sendNumber
c.
initializeNumber
b.
writeNumber
d.
setNumber
 

73. 

The difference between a text field object and a text area object is:
a.
a text field can handle several lines of text
b.
a text field can only handle integers
c.
a text area can handle several lines of text
d.
no difference
 

74. 

What does the isValid method do in the integer field class?
a.
determines whether the number entered is positive
b.
determines whether the number entered is a valid integer
c.
determines whether a value was entered
d.
determines whether the object was instantiated correctly
 

75. 

Which method is not implemented by all window controls?
a.
isValid
c.
setEnabled
b.
setVisible
d.
requestFocus
 

76. 

What is the Swing toolkit's default look and feel?
a.
Metal
c.
Windows
b.
Motif
d.
Mac
 

77. 

Which of the following is NOT a justification in the BreezySwing method Format.justify( ... )?
a.
Left
c.
Middle
b.
Right
d.
Center
 

78. 

How many blank spaces appear in front of the number in the output of the following code:
     System.out.println( Format.justify( 'r', 3.25823, 10, 3 ) );
a.
3
c.
5
b.
7
d.
4
 

79. 

A ___________ shows the relationship between a method and its helper methods.
a.
flow chart
c.
pseudocode
b.
truth table
d.
structure chart
 

80. 

What is the minimum number of columns a window will have if the following Java instruction is included:
     doubleField field3 = addDoubleField( 0, 4, 2, 1, 3);
a.
0
c.
2
b.
3
d.
1
 

81. 

What does the first parameter of an add method specify?
a.
the object's initial value
c.
the object's row number
b.
the object's height
d.
the object's column number
 

82. 

Labels are part of Swing, whereas __________ are derived from objects in Swing.
a.
command buttons
c.
text areas
b.
double fields
d.
text fields
 

83. 

What does the setEnabled( true ) method do?
a.
move focus to the control
c.
makes control visible
b.
hides the control
d.
sets the control to receive user input
 

84. 

Which of the following is NOT a method of a JButton object?
a.
setText
c.
setEnabled
b.
setLabel
d.
setVisible
 

85. 

What is the correct Java code for the following output.( note: underscores "_" are designated as blanks for readability )
_ _ _ _ 3.963
a.
System.out.println( Format.justify( 'l', 3.96349, 9, 3 ) );
b.
System.out.println( Format.justify( 'c', 3.963, 8, 4 ) );
c.
System.out.println( Format.justify( 'r', 3.96349, 9, 3 ) );
d.
System.out.println( Format.justify( 'r', 3.963, 9, 5 ) );
 

Completion
Complete each sentence or statement.
 

86. 

An object has _________ as defined by the methods of its class.
 

 

87. 

If a reference variable of an object is set to _______, and no other variable points to that object, the computer reclaims the object's memory during garbage collection.
 

 

88. 

Using the visibility modifier __________ for instance variables is an important aspect of information hiding.
 

 

89. 

Constructors with empty parameter lists are called ___________ constructors.
 

 

90. 

Parameters listed in a method's definition are called ________ parameters.
 

 

91. 

Methods that are usually private that help break down tasks to reduce complexity are called _________ methods.
 

 

92. 

A programmer uses the symbol ______ to refer to the current instance of a class within that class's definition.
 

 

93. 

The default width of a pen in turtle graphics is two ________, or picture elements.
 

 

94. 

The operator _____ changes the truth value of a condition to the opposite value, i.e. if the operand is true, then this operator makes the condition false.
 

 

95. 

When a loop is placed within another loop it is called a __________ loop.
 

 

96. 

A ________ _________ can determine the value of any complex Boolean expression.
 

 

Short Answer
 

97. 

When messages are sent, which two objects are involved?
 

98. 

Assuming A is true, B is false and C is true, what is the value of the following boolean expression?

      ( A && !B ) || !C
 

99. 

What two packages need to be imported to build a GUI program?
 



 
Check Your Work     Reset Help