SP26 IST 1714-VA1 - Java Programming Language - Finale Exam

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/159

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:50 PM on 4/23/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

160 Terms

1
New cards
A _____ chooses among alternative courses of action based on some value within a program.
decision structure
2
New cards
A _____ is separated with a question mark and a colon.
conditional operator
3
New cards
A(n) _____ is particularly useful when two conditions must be met before some action is taken.
nested if statement
4
New cards
Although it is possible to block statements that depend on an if, you cannot likewise block statements that depend on an else.
False
5
New cards
Based on the flowchart, which decision statement will correctly check that hoursWorked is greater than or equal to the FULL_WEEK constant?
hoursWorked >= FULL_WEEK
6
New cards
Computers contain switches that are set to on or off.
True
7
New cards
Just as you can block statements that depend on an if, you can also block statements that depend on a(n) _____.
else
8
New cards
The AND operator is written as two _____.
ampersands ( && )
9
New cards
The _____ operator is written as the exclamation point (!).
NOT
10
New cards
The _____ statement is useful when you need to test a single variable against a series of exact integer, character, or string values.
switch
11
New cards
The compiler does not take indentation into account when compiling code, but consistent indentation can help readers understand a program’s _____.
logic
12
New cards
The conditional operator requires three expressions separated with a question mark and a colon.
True
13
New cards
The disadvantage to using the conditional operator is that it _____.
can be difficult to read
14
New cards
The expressions on each side of the && and || operators are evaluated only as far as necessary to determine whether the entire expression is true or false. This feature is called a _____.
short-circuit evaluation
15
New cards
The logical structure called a(n) _____ structure is one where one step follows another unconditionally.
sequence
16
New cards
The simplest statement you can use to make a decision is the _____ statement.
if
17
New cards
When using equals and not equals for comparisons with objects, you compare the objects’ _____ instead of actual values.
memory addresses
18
New cards
When writing an if statement with the two-line format, you must be sure to type a semicolon at the end of the first line in order to ensure accurate results.
False
19
New cards
When you create a block, you must place multiple statements within it.
False
20
New cards
When you place a block within an if statement, it is crucial to place the _____ correctly.
curly braces
21
New cards
When you use the && operator, you must include a complete _____ on each side.
Boolean expression
22
New cards
Which of the following switch expressions determines whether a number between 1 to 5 is even or odd?
switch (number) { case 1, 3, 5 -> System.out.println("Odd number"); case 2,4 -> System.out.println ("Even number"); default -> System.out.println("Invalid number"); }
23
New cards
You are never required to use a switch structure; you can always achieve the same results with _____ statements.
nested if
24
New cards
You use the NOT operator, which is written as the exclamation point ( ! ), to negate the result of any Boolean expression.
True
25
New cards
_____ requires three expressions separated with a question mark and a colon.
The conditional operator
26
New cards
A _____ consists of written steps in diagram form, as a series of shapes connected by arrows.
flowchart
27
New cards
A(n) _____ is a series of if statements that determine whether a value falls within a specified range.
range check
28
New cards
A(n) _____ statement is the decision structure you use when you need to take one or the other of two possible courses of action.
dual-alternative if
29
New cards
An alternative to using a Boolean expression, such as someVariable == 10, is to store the Boolean expression’s value in a boolean type variable.
True
30
New cards
Both & and | are valid Java operators, but a single & or | with integer operands operates on individual _____ rather than making comparisons in logical conditions as && and || do.
bits
31
New cards
In the switch structure, break is followed by one of the possible values for the test expression and a colon.
False
32
New cards
Statements in which an if structure is contained inside another if structure are commonly called _____ if statements.
nested
33
New cards
The _____ operator is always evaluated before the OR operator.
AND
34
New cards
When working with logical operators, you can always use _____ to change precedence.
parentheses
35
New cards
When you block statements, you must remember that any _____ you declare within a block is local to that block.
variable
36
New cards
When you execute an if…else statement, only one of the resulting actions takes place depending on the evaluation of the _____ following the if.
Boolean expression
37
New cards
When you use nested if statements, you must pay careful attention to the placement of any else clauses.
True
38
New cards
Which of the following options determine equivalency?
A double equal sign (==)
39
New cards
Which operator has the highest precedence?
NOT ( ! )
40
New cards
You can use the _____, which is written as ||, if you want some action to occur when at least one of two conditions is true.
conditional OR operator
41
New cards
You write pseudocode in everyday language, not the syntax used in a programming language.
True
42
New cards
A _____ is a structure that allows repeated execution of a block of statements.
loop
43
New cards
A for loop provides a convenient way to create a(n) _____ loop.
counter-controlled
44
New cards
A loop that never ends is called a(n) _____.
infinite loop
45
New cards
A(n) ____ loop is one that performs no actions other than looping.
do-nothing
46
New cards
A(n) _____ loop is a special loop that is used when a definite number of loop iterations is required.
for
47
New cards
Before entering a loop, the first input statement, or the ____, is retrieved.
priming read
48
New cards
How many times will outputLabel be called?
60
49
New cards
In a do…while loop, the loop will continue to execute until ____.
the loop control variable is false
50
New cards
In the expressions b = 8 and c = --b, what value will be assigned to the variable c?
7
51
New cards
Making a comparison to 0 is slower than making a comparison to any other value.
False
52
New cards
Many seasoned programmers start counter values at 1 because they are used to doing so when working with arrays.
False
53
New cards
One execution of any loop is called a(n) _____.
iteration
54
New cards
Shortcut operators are a programmer’s only choice when incrementing or accumulating a variable’s value.
False
55
New cards
The _____ loop is the posttest loop used in Java.
do ... while
56
New cards
The process of repeatedly increasing a value by some amount is known as _____.
accumulating
57
New cards
Use a(n) ____ loop to execute a body of statements continually as long as the Boolean expression that controls entry into the loop continues to be true.
while
58
New cards
What is wrong with the following code?
A semicolon at the end of the while expression
59
New cards
What kind of loop is the following code?
Event-driven
60
New cards
When nesting loops, the variable in the outer loop changes more frequently.
False
61
New cards
Which of the following is an illegal method to increase a variable named score by 1?
++score = score + 1
62
New cards
Consider int value=24. Which of the following postfix increment operators adds 1 to a value?
value++
63
New cards
With _____ loops, the order of the conditional expressions can be important.
nested
64
New cards
You can initialize one or more variables in the first section of a for statement.
True
65
New cards
You use a unary minus sign preceding a value to make the value _____.
negative
66
New cards
_____ is the process of ensuring that a value falls within a specified range.
Validating data
67
New cards
A counted loop is the same as an indefinite loop.
False
68
New cards
A(n) ____ is a kind of indefinite loop.
event-controlled loop
69
New cards
A(n) _____ is a body with no statements in it.
empty body
70
New cards
Assume d and x are integers: d = 5; x = 2 * ++d; What is the value of x?
12
71
New cards
In order to improve loop performance, it’s important to make sure the loop does not include unnecessary operations or statements.
True
72
New cards
It is important that the loop control ____ be altered within the body of the loop.
variable
73
New cards
Programmers rarely use indefinite loops when validating input data.
False
74
New cards
The ____ loop checks the value of the loop control variable at the bottom of the loop after one repetition has occurred.
do…while
75
New cards
The statements that make up a loop body will continue to execute as long as the expression value remains false.
False
76
New cards
What is the output of the following code? int loopCount = 1; while(loopCount < 3) { System.out.println("Hello"); loopCount = loopCount + 1; }
Hello
77
New cards
Hello
What is the output of the following code? int loopCount = 1; while(loopCount < 3) System.out.println("Hello"); loopCount = loopCount + 1;
78
New cards
This is an infinite loop.
What is the output of the following code? for (int loop = 1; loop
79
New cards
122122
What is the output of the following code? int loopCount = 3; while(loopCount > 1) { System.out.println("Hello"); loopCount = loopCount - 1; }
80
New cards
Hello
Hello
81
New cards
What is wrong with the following code? while (4>2) System.out.println ("Hi there");
An infinite loop
82
New cards
When creating a for loop, which statement will correctly initialize more than one variable?
for(a=1, b=2)
83
New cards
When you want to increase a variable’s value by exactly 1, use the _____.
prefix increment operator
84
New cards
Which of the following is an infinite loop? loopCount = 1; while(loopCount < 3); { System.out.println("Hello"); }
The semicolon after the while condition creates an empty body infinite loop.
85
New cards
Consider int value=24. Which of the following prefix increment operators adds 1 to a value?
++value
86
New cards
You can use virtually any number of nested loops; however, at some point, your machine will no longer be able to store all the necessary looping information.
True
87
New cards
_____ is a technique that can improve loop performance by combining two loops into one.
Loop fusion
88
New cards
A StringBuilder object contains a memory block called a _____, which might or might not contain a string.
buffer
89
New cards
A _____ is a class for storing and manipulating changeable data that is composed of multiple characters.
StringBuilder
90
New cards
A literal string is a(n) _____ object.
anonymous
91
New cards
A(n) _____ comparison is based on the integer Unicode values of the characters.
lexicographical
92
New cards
A(n) _____ is a variable that holds a memory address.
reference
93
New cards
String oneStr = "Welcome Jim" String twoStr = "Welcome Joe" Given the lines of code, which of the following regionMatches () expressions will result in a value of true?
oneStr.regionMatches(0, twoStr, 0, 7)
94
New cards
String s and other objects that can’t be changed are known as _____.
immutable
95
New cards
System.out.println("Your name is " + yourName); The statement provided is an example of _____, which is used to join Strings.
concatenation
96
New cards
The Character class _____ java.lang.Object.
inherits from
97
New cards
The String class _____ method evaluates the contents of two String objects to determine if they are equivalent.
equals()
98
New cards
The String class _____ method is similar to the equals() method... this method does not consider case...
equalsIgnoreCase()
99
New cards
The _____ method allows you to replace all occurrences of some character within a String.
replace()
100
New cards
The _____ method lets you add characters at a specific location within a StringBuilder object.
insert()