Deck 3: Flow of Control

ملء الشاشة (f)
exit full mode
سؤال
A compound statement is enclosed between:
(a)[ ]
(b){ }
(c)( )
(d)< >
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
The looping mechanism that always executes at least once is the _____________ statement.
(a)if…else
(b)do…while
(c)while
(d)for
سؤال
In a switch statement,the default case is always executed.
سؤال
To compare two strings lexicographically the String method ____________ should be used.
(a)equals
(b)equalsIgnoreCase
(c)compareTo
(d)==
سؤال
Common loop errors are:
(a)Off-by-one
(b)Infinite loops
(c)Both a and b
(d)None of the above
سؤال
An if-else statement chooses between two alternative statements based on the value of a Boolean expression.
سؤال
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
سؤال
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.
سؤال
A mixture of programming language and human language is known as:
(a)Algorithms
(b)Recipes
(c)Directions
(d)Pseudocode
سؤال
The ____________ operator has the highest precedence.
(a)*
(b)dot
(c)+=
(d)decrement
سؤال
The controlling expression for a switch statement includes all of the following types except:
(a)char
(b)int
(c)byte
(d)double
سؤال
In a switch statement,the choice of which branch to execute is determined by an expression given in parentheses after the keyword switch.
سؤال
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.
سؤال
The OR operator in Java is represented by:
(a)!
(b)&&
(c)| |
(d)None of the above
سؤال
A ___________ statement terminates the current iteration of a loop.
(a)Break
(b)Continue
(c)Switch
(d)Assert
سؤال
To terminate a program,use the Java statement:
(a)System.quit(0);
(b)System.end(0);
(c)System.abort(0);
(d)System.exit(0);
سؤال
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 association of operands with operators is called ______________.
(a)assignment
(b)precedence
(c)binding
(d)lexicographic ordering
سؤال
The negation operator in Java is represented by:
(a)!
(b)&&
(c)| |
(d)None of the above
سؤال
What output will be produced by the following code?
public class SelectionStatements
{
public static void main(String[] args)
{
int number = 24;
if(number % 2 == 0)
System.out.print("The condition evaluated to true!");
else
System.out.print("The condition evaluated to false!");
}
}
سؤال
When choosing a sentinel value,you should choose a value that would never be encountered in the input of the program.
سؤال
The three expressions at the start of a for statement are separated by two commas.
سؤال
Name and describe three types of branching mechanisms and give an example of each.
سؤال
Evaluate the Boolean equation: !( ( 6 < 5)&& (4 < 3))
سؤال
Discuss the rules Java follows when evaluating expressions.
سؤال
Write Java code that uses a for statement to sum the numbers from 1 through 50.Display the total sum to the console.
سؤال
What is a sentinel value and how is it used?
سؤال
What is short-circuit evaluation of Boolean expressions?
سؤال
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.
سؤال
What would be the output of the code in #1 if number was originally initialized to 25?
سؤال
Not including the break statements within a switch statement results in a syntax error.
سؤال
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!
سؤال
An algorithm is a step-by-step method of solution.
سؤال
Write Java code that uses a while loop to print even numbers from 2 through 10.
سؤال
The equality operator (==)may be used to test if two string objects contain the same value.
سؤال
An empty statement is defined as a loop that runs forever.
سؤال
The for statement,do…while statement and while statement are examples of branching mechanisms.
سؤال
Boolean expressions are used to control branch and loop statements.
سؤال
Write Java code that uses a do…while loop that prints even numbers from 2 through 10.
سؤال
What is the output of the following code segment?
public static void main(String[] args)
{
int x = 5;
System.out.println("The value of x is:" + x);
while(x > 0)
{
x++;
}
System.out.println("The value of x is:" + x);
}
سؤال
Discuss the differences between the break and the continue statements when used in looping mechanisms.
سؤال
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.
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/43
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 3: Flow of Control
1
A compound statement is enclosed between:
(a)[ ]
(b){ }
(c)( )
(d)< >
B
2
The looping mechanism that always executes at least once is the _____________ statement.
(a)if…else
(b)do…while
(c)while
(d)for
B
3
In a switch statement,the default case is always executed.
False
4
To compare two strings lexicographically the String method ____________ should be used.
(a)equals
(b)equalsIgnoreCase
(c)compareTo
(d)==
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
5
Common loop errors are:
(a)Off-by-one
(b)Infinite loops
(c)Both a and b
(d)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
6
An if-else statement chooses between two alternative statements based on the value of a Boolean expression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
7
You may omit the else part of an if-else statement if no alternative action is required.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
8
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
9
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
10
A mixture of programming language and human language is known as:
(a)Algorithms
(b)Recipes
(c)Directions
(d)Pseudocode
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
11
The ____________ operator has the highest precedence.
(a)*
(b)dot
(c)+=
(d)decrement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
12
The controlling expression for a switch statement includes all of the following types except:
(a)char
(b)int
(c)byte
(d)double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
13
In a switch statement,the choice of which branch to execute is determined by an expression given in parentheses after the keyword switch.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
14
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
15
The OR operator in Java is represented by:
(a)!
(b)&&
(c)| |
(d)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
16
A ___________ statement terminates the current iteration of a loop.
(a)Break
(b)Continue
(c)Switch
(d)Assert
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
17
To terminate a program,use the Java statement:
(a)System.quit(0);
(b)System.end(0);
(c)System.abort(0);
(d)System.exit(0);
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
19
The association of operands with operators is called ______________.
(a)assignment
(b)precedence
(c)binding
(d)lexicographic ordering
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
20
The negation operator in Java is represented by:
(a)!
(b)&&
(c)| |
(d)None of the above
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
21
What output will be produced by the following code?
public class SelectionStatements
{
public static void main(String[] args)
{
int number = 24;
if(number % 2 == 0)
System.out.print("The condition evaluated to true!");
else
System.out.print("The condition evaluated to false!");
}
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
22
When choosing a sentinel value,you should choose a value that would never be encountered in the input of the program.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
23
The three expressions at the start of a for statement are separated by two commas.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
24
Name and describe three types of branching mechanisms and give an example of each.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
25
Evaluate the Boolean equation: !( ( 6 < 5)&& (4 < 3))
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
26
Discuss the rules Java follows when evaluating expressions.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
27
Write Java code that uses a for statement to sum the numbers from 1 through 50.Display the total sum to the console.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
28
What is a sentinel value and how is it used?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
29
What is short-circuit evaluation of Boolean expressions?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
30
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
31
What would be the output of the code in #1 if number was originally initialized to 25?
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
32
Not including the break statements within a switch statement results in a syntax error.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
33
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!
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
34
An algorithm is a step-by-step method of solution.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
35
Write Java code that uses a while loop to print even numbers from 2 through 10.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
36
The equality operator (==)may be used to test if two string objects contain the same value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
37
An empty statement is defined as a loop that runs forever.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
38
The for statement,do…while statement and while statement are examples of branching mechanisms.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
39
Boolean expressions are used to control branch and loop statements.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
40
Write Java code that uses a do…while loop that prints even numbers from 2 through 10.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
41
What is the output of the following code segment?
public static void main(String[] args)
{
int x = 5;
System.out.println("The value of x is:" + x);
while(x > 0)
{
x++;
}
System.out.println("The value of x is:" + x);
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
42
Discuss the differences between the break and the continue statements when used in looping mechanisms.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
43
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 43 في هذه المجموعة.