Deck 3: Flow of Control

ملء الشاشة (f)
exit full mode
سؤال
To compare two strings lexicographically the String method ____________ should be used.

A)equals
B)equalsIgnoreCase
C)compareTo
D)==
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The association of operands with operators is called ______________.

A)assignment
B)precedence
C)binding
D)lexicographic ordering
سؤال
To terminate a program,use the Java statement:

A)System.quit0);
B)System.end0);
C)System.abort0);
D)System.exit0);
سؤال
A ___________ statement terminates the current iteration of a loop.

A)Break
B)Continue
C)Switch
D)Assert
سؤال
The ____________ operator has the highest precedence.

A)*
B)dot
C)+=
D)decrement
سؤال
In a switch statement,the choice of which branch to execute is determined by an expression given in parentheses after the keyword switch.
سؤال
The controlling expression for a switch statement includes all of the following types except:

A)char
B)int
C)byte
D)double
سؤال
The OR operator in Java is represented by:

A)!
B)&&
C)| |
D)None of the above
سؤال
The negation operator in Java is represented by:

A)!
B)&&
C)| |
D)None of the above
سؤال
A mixture of programming language and human language is known as:

A)Algorithms
B)Recipes
C)Directions
D)Pseudocode
سؤال
An if selection statement executes if and only if:

A)the Boolean condition evaluates to false.
B)the Boolean condition evaluates to true.
C)the Boolean condition is short-circuited.
D)none of the above.
سؤال
When using a compound Boolean expression joined by an && AND)in an if statement:

A)Both expressions must evaluate to true for the statement to execute.
B)The first expression must evaluate to true and the second expression must evaluate to false for the statement to execute.
C)The first expression must evaluate to false and the second expression must evaluate to true for the statement to execute.
D)Both expressions must evaluate to false for the statement to execute.
سؤال
An if-else statement chooses between two alternative statements based on the value of a Boolean expression.
سؤال
A compound statement is enclosed between:

A)[ ]
B){ }
C))
D)< >
سؤال
You may omit the else part of an if-else statement if no alternative action is required.
سؤال
When the number of repetitions are known in advance,you should use a ___________ statement.

A)while
B)do…while
C)for
D)None of the above
سؤال
Common loop errors are:

A)Off-by-one
B)Infinite loops
C)Both a and b
D)None of the above
سؤال
A multi-way if-else statement

A)allows you to choose one course of action.
B)always executes the else statement.
C)allows you to choose among alternative courses of action.
D)executes all Boolean conditions that evaluate to true.
سؤال
The looping mechanism that always executes at least once is the _____________ statement.

A)if…else
B)do…while
C)while
D)for
سؤال
Good debugging techniques include:

A)Inserting output statements in your program.
B)Tracing variables
C)Using an IDE debugger
D)All of the above
سؤال
What is a sentinel value and how is it used?
سؤال
The three expressions at the start of a for statement are separated by two commas.
سؤال
Write a multi-way if-else statement that evaluates a persons weight on the following criteria: A weight less than 115 pounds,output: Eat 5 banana splits! A weight between 116 pounds and 130 pounds,output: Eat a banana split! A weight between 131 pounds and 200 pounds,output: Perfect! A weight greater than 200 pounds,output: Plenty of banana splits have been consumed!
سؤال
What output will be produced by the following code?
public class SelectionStatements
{
public static void mainString[] args)
{
int number = 24;
ifnumber % 2 == 0)
System.out.print"The condition evaluated to true!");
else
System.out.print"The condition evaluated to false!");
}
}
سؤال
An algorithm is a step-by-step method of solution.
سؤال
Evaluate the Boolean equation: ! 6 < 5)&& 4 < 3))
سؤال
Boolean expressions are used to control branch and loop statements.
سؤال
The equality operator ==)may be used to test if two string objects contain the same value.
سؤال
What would be the output of the code in #1 if number was originally initialized to 25?
سؤال
An empty statement is defined as a loop that runs forever.
سؤال
Write Java code that uses a while loop to print even numbers from 2 through 10.
سؤال
The for statement,do…while statement and while statement are examples of branching mechanisms.
سؤال
Name and describe three types of branching mechanisms and give an example of each.
سؤال
Not including the break statements within a switch statement results in a syntax error.
سؤال
When choosing a sentinel value,you should choose a value that would never be encountered in the input of the program.
سؤال
Write an if-else statement to compute the amount of shipping due on an online sale.If the cost of the purchase is less than $20,the shipping cost is $5.99.If the cost of the purchase over $20 and at most $65,the shipping cost is $10.99.If the cost of the purchase is over $65,the shipping cost is $15.99.
سؤال
In a switch statement,the default case is always executed.
سؤال
Write Java code that uses a do…while loop that prints even numbers from 2 through 10.
سؤال
Discuss the rules Java follows when evaluating expressions.
سؤال
What is short-circuit evaluation of Boolean expressions?
سؤال
Write a complete Java program that prompts the user for a series of numbers to determine the smallest value entered.Before the program terminates,display the smallest value.
سؤال
Write Java code that uses a for statement to sum the numbers from 1 through 50.Display the total sum to the console.
سؤال
Discuss the differences between the break and the continue statements when used in looping mechanisms.
سؤال
What is the output of the following code segment?
public static void mainString[] args)
{
int x = 5;
System.out.println"The value of x is:" + x);
whilex > 0)
{
x++;
}
System.out.println"The value of x is:" + x);
}
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/44
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Flow of Control
1
To compare two strings lexicographically the String method ____________ should be used.

A)equals
B)equalsIgnoreCase
C)compareTo
D)==
C
2
The association of operands with operators is called ______________.

A)assignment
B)precedence
C)binding
D)lexicographic ordering
C
3
To terminate a program,use the Java statement:

A)System.quit0);
B)System.end0);
C)System.abort0);
D)System.exit0);
D
4
A ___________ statement terminates the current iteration of a loop.

A)Break
B)Continue
C)Switch
D)Assert
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
5
The ____________ operator has the highest precedence.

A)*
B)dot
C)+=
D)decrement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
6
In a switch statement,the choice of which branch to execute is determined by an expression given in parentheses after the keyword switch.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
7
The controlling expression for a switch statement includes all of the following types except:

A)char
B)int
C)byte
D)double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
8
The OR operator in Java is represented by:

A)!
B)&&
C)| |
D)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
9
The negation operator in Java is represented by:

A)!
B)&&
C)| |
D)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
10
A mixture of programming language and human language is known as:

A)Algorithms
B)Recipes
C)Directions
D)Pseudocode
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
11
An if selection statement executes if and only if:

A)the Boolean condition evaluates to false.
B)the Boolean condition evaluates to true.
C)the Boolean condition is short-circuited.
D)none of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
12
When using a compound Boolean expression joined by an && AND)in an if statement:

A)Both expressions must evaluate to true for the statement to execute.
B)The first expression must evaluate to true and the second expression must evaluate to false for the statement to execute.
C)The first expression must evaluate to false and the second expression must evaluate to true for the statement to execute.
D)Both expressions must evaluate to false for the statement to execute.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
13
An if-else statement chooses between two alternative statements based on the value of a Boolean expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
14
A compound statement is enclosed between:

A)[ ]
B){ }
C))
D)< >
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
15
You may omit the else part of an if-else statement if no alternative action is required.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
16
When the number of repetitions are known in advance,you should use a ___________ statement.

A)while
B)do…while
C)for
D)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
17
Common loop errors are:

A)Off-by-one
B)Infinite loops
C)Both a and b
D)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
18
A multi-way if-else statement

A)allows you to choose one course of action.
B)always executes the else statement.
C)allows you to choose among alternative courses of action.
D)executes all Boolean conditions that evaluate to true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
19
The looping mechanism that always executes at least once is the _____________ statement.

A)if…else
B)do…while
C)while
D)for
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
20
Good debugging techniques include:

A)Inserting output statements in your program.
B)Tracing variables
C)Using an IDE debugger
D)All of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
21
What is a sentinel value and how is it used?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
22
The three expressions at the start of a for statement are separated by two commas.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
23
Write a multi-way if-else statement that evaluates a persons weight on the following criteria: A weight less than 115 pounds,output: Eat 5 banana splits! A weight between 116 pounds and 130 pounds,output: Eat a banana split! A weight between 131 pounds and 200 pounds,output: Perfect! A weight greater than 200 pounds,output: Plenty of banana splits have been consumed!
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
24
What output will be produced by the following code?
public class SelectionStatements
{
public static void mainString[] args)
{
int number = 24;
ifnumber % 2 == 0)
System.out.print"The condition evaluated to true!");
else
System.out.print"The condition evaluated to false!");
}
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
25
An algorithm is a step-by-step method of solution.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
26
Evaluate the Boolean equation: ! 6 < 5)&& 4 < 3))
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
27
Boolean expressions are used to control branch and loop statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
28
The equality operator ==)may be used to test if two string objects contain the same value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
29
What would be the output of the code in #1 if number was originally initialized to 25?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
30
An empty statement is defined as a loop that runs forever.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
31
Write Java code that uses a while loop to print even numbers from 2 through 10.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
32
The for statement,do…while statement and while statement are examples of branching mechanisms.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
33
Name and describe three types of branching mechanisms and give an example of each.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
34
Not including the break statements within a switch statement results in a syntax error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
35
When choosing a sentinel value,you should choose a value that would never be encountered in the input of the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
36
Write an if-else statement to compute the amount of shipping due on an online sale.If the cost of the purchase is less than $20,the shipping cost is $5.99.If the cost of the purchase over $20 and at most $65,the shipping cost is $10.99.If the cost of the purchase is over $65,the shipping cost is $15.99.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
37
In a switch statement,the default case is always executed.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
38
Write Java code that uses a do…while loop that prints even numbers from 2 through 10.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
39
Discuss the rules Java follows when evaluating expressions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
40
What is short-circuit evaluation of Boolean expressions?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
41
Write a complete Java program that prompts the user for a series of numbers to determine the smallest value entered.Before the program terminates,display the smallest value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
42
Write Java code that uses a for statement to sum the numbers from 1 through 50.Display the total sum to the console.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
43
Discuss the differences between the break and the continue statements when used in looping mechanisms.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
44
What is the output of the following code segment?
public static void mainString[] args)
{
int x = 5;
System.out.println"The value of x is:" + x);
whilex > 0)
{
x++;
}
System.out.println"The value of x is:" + x);
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 44 في هذه المجموعة.