Deck 4: Decision Structures

ملء الشاشة (f)
exit full mode
سؤال
Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?

A) str1.equalsIgnoreCase(str2)
B) str1.equalsInsensitive(str2)
C) str1 != str2
D) str1 || str2
استخدم زر المسافة أو
up arrow
down arrow
لقلب البطاقة.
سؤال
When testing for character values, the switch statement does not test for the case of the character.
سؤال
The DecimalFormat class is part of the Java API so it is automatically available to your programs.
سؤال
The boolean expression in an if statement must evaluate to

A) degrees or radians
B) true or false
C) positive or negative
D) left or right
سؤال
__________ operators are used to determine whether a specific relationship exists between two values.

A) Assignment
B) Arithmetic
C) Logical
D) Relational
سؤال
In an if-else statement, if the boolean expression is false

A) no statements or blocks are executed
B) the statement or block following the else is executed
C) the first statement or block is executed
D) all the statements or blocks are executed
سؤال
All it takes for an AND expression to be true is for one of the subexpressions to be true.
سؤال
A flag may have the values

A) defined or undefined
B) true or false
C) of any range of integers
D) of any Unicode character
سؤال
Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8?

A) "###.#"
B) "###.0"
C) "000.0"
D) "#0.00%"
سؤال
A block of code is enclosed in a set of

A) braces, { }
B) parentheses, ( )
C) brackets, [ ]
D) double quotes, " "
سؤال
If the expression on the left side of the && operator is false, the expression on the right side will not be checked.
سؤال
Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%?

A) "##0.0%"
B) "###.##%"
C) "000.0%"
D) "#0.00%"
سؤال
When two strings are compared using the String class's compareTo method, the comparison is not case sensitive.
سؤال
Unicode is an international encoding system that is extensive enough to represent all the characters of all the world's alphabets.
سؤال
A random number, created as an object of the Random class, is always an integer.
سؤال
In a switch statement, if two different values for the CaseExpression would result in the same code being executed, you must have two copies of the code, one after each CaseExpression.
سؤال
All it takes for an OR expression to be true is for one of the subexpressions to be true.
سؤال
An important style rule that should be used when writing if statements is to write the conditionally executed statement on the line after the if statement.
سؤال
If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?

A) str1 = str2
B) str1 && str2
C) str1.equals(str2)
D) str1 += str2
سؤال
The if-else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false.
سؤال
Which of the following expressions will generate a random number in the range of 1 through 10?

A) myNumber = randomNumbers.nextInt(10);
B) myNumber = randomNumbers.nextInt(1) + 10;
C) myNumber = randomNumbers.nextInt(11) - 1;
D) myNumber = randomNumbers.nextInt(10) + 1;
سؤال
What will be the value of x after the following statements are executed?
int x = 75;
Int y = 60;
If (x > y)
X = x - y;

A) 60
B) 75
C) 15
D) 135
سؤال
What will be displayed after the following statements are executed?
int x = 65;
Int y = 55;
If (x >= y)
{
Int ans = x + y;
}
System.out.println(ans);

A) 10
B) 120
C) 100
D) The code contains an error and will not compile.
سؤال
What will be the values of ans, x, and y after the following statements are executed?
int ans = 35, x = 50, y = 50;
If (x >= y)
{
Ans = x + 10;
X -= y;
}
Else
{
Ans = y + 10;
Y += x;
}

A) ans = 60, x = 0, and y = 50
B) ans = 45, x = 50, and y = 0
C) ans = 45, x = 50, and y = 50
D) ans = 60, x = 50, and y = 100
سؤال
What will be the value of ans after the following statements are executed?
int x = 40;
Int y = 40;
If (x = y)
Ans = x + 10;

A) 30
B) 80
C) 50
D) The code contains an error and will not compile.
سؤال
The __________ statement is used to create a decision structure which allows a program to have more than one path of execution.

A) block
B) if
C) null
D) flag
سؤال
A __________ is a boolean variable that signals when some condition exists in the program.

A) sentinel
B) flag
C) block
D) case
سؤال
Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)?

A) if (temp >= 0 && temp <= 100)
B) if (temp > 0 && temp < 100)
C) if (temp >= 0 || temp <= 100)
D) if (temp > 0 || temp < 100)
سؤال
What will be displayed after the following statements are executed?
int hours = 30;
Double pay, payRate = 10.00;
Pay = hours <= 40 ? hours*payRate : hours*payRate*2.0;
System.out.println(pay);

A) 300.0
B) 600.0
C) 400.0
D) The code contains an error and will not compile.
سؤال
Enclosing a group of statements inside a set of braces creates

A) an expression
B) a block of statements
C) a relational operator
D) a conditional statement
سؤال
Which of the following expressions determines whether the char variable, chrA, is not equal to the letter 'A'?

A) chrA == 'A'
B) chrA != 'A'
C) chrA || 'A'
D) chrA.notEquals(A)
سؤال
Java requires that the boolean expression being tested by an if statement be enclosed in

A) a set of parentheses
B) a set of braces
C) a set of double quotes
D) a set of brackets
سؤال
What will be the value of discountRate after the following statements are executed?
double discountRate;
Char custType = 'B';
Switch (custType)
{
Case 'A':
DiscountRate = 0.08;
Break;
Case 'B':
DiscountRate = 0.06;
Case 'C':
DiscountRate = 0.04;
Default:
DiscountRate = 0.0;
}

A) 0.08
B) 0.06
C) 0.04
D) 0.0
سؤال
What will be the value of discountRate after the following statements are executed?
double discountRate = 0.0;
Int purchase = 100;
If (purchase > 1000)
DiscountRate = 0.05;
Else if (purchase > 750)
DiscountRate = 0.03;
Else if (purchase > 500)
DiscountRate = 0.01;

A) 0.0
B) 0.05
C) 0.03
D) 0.01
سؤال
When a character is stored in memory, it is actually the __________ that is stored.

A) Unicode number
B) ASCII code
C) floating-point value
D) letter, symbol, or number
سؤال
Which of the following expressions will determine whether x is less than or equal to y?

A) x <= y
B) x => y
C) x >= y
D) x =< y
سؤال
What will be the value of bonus after the following statements are executed? int bonus, sales = 10000;
If (sales < 5000)
Bonus = 200;
Else if (sales < 7500)
Bonus = 500;
Else if (sales < 10000)
Bonus = 750;
Else if (sales < 20000)
Bonus = 1000;
Else
Bonus = 1250;

A) 750
B) 1250
C) 500
D) 1000
سؤال
What will be the value of discountRate after the following statements are executed?
double discountRate = 0.0;
Int purchase = 1250;
Char cust = 'N';
If (purchase > 1000)
If (cust == 'Y')
DiscountRate = 0.05;
Else
DiscountRate = 0.04;
Else if (purchase > 750)
If (cust == 'Y')
DiscountRate = 0.04;
Else
DiscountRate = 0.03;
Else
DiscountRate = 0.0;

A) 0.0
B) 0.04
C) 0.05
D) 0.03
سؤال
What will be displayed after the following statements are executed?
int y = 10;
If (y == 10)
{
Int x = 30;
X += y;
System.out.println(x);
}

A) 40
B) 30
C) 20
D) The code contains an error and will not compile.
سؤال
What will be the value of x after the following statements are executed?
int x = 10;
Switch (x)
{
Case 10:
X += 15;
Case 12:
X -= 5;
Break;
Default:
X *= 3;
}

A) 30
B) 20
C) 25
D) 5
سؤال
Select all that apply. Which method of the Random class will return a random number within the range of 0.0 and 1.0?

A) nextDouble()
B) nextLong()
C) nextFloat()
D) nextInt(int n)
سؤال
Which of the following statements will create an object from the Random class?

A) randomNumbers() = new Random();
B) Random myNumber = new Random();
C) myNumber = new Random();
D) Random = new randomNumbers();
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/42
auto play flashcards
العب
simple tutorial
ملء الشاشة (f)
exit full mode
Deck 4: Decision Structures
1
Which of the following expressions could be used to perform a case-insensitive comparison of two String objects named str1 and str2?

A) str1.equalsIgnoreCase(str2)
B) str1.equalsInsensitive(str2)
C) str1 != str2
D) str1 || str2
A
2
When testing for character values, the switch statement does not test for the case of the character.
False
3
The DecimalFormat class is part of the Java API so it is automatically available to your programs.
False
4
The boolean expression in an if statement must evaluate to

A) degrees or radians
B) true or false
C) positive or negative
D) left or right
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
5
__________ operators are used to determine whether a specific relationship exists between two values.

A) Assignment
B) Arithmetic
C) Logical
D) Relational
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
6
In an if-else statement, if the boolean expression is false

A) no statements or blocks are executed
B) the statement or block following the else is executed
C) the first statement or block is executed
D) all the statements or blocks are executed
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
7
All it takes for an AND expression to be true is for one of the subexpressions to be true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
8
A flag may have the values

A) defined or undefined
B) true or false
C) of any range of integers
D) of any Unicode character
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8?

A) "###.#"
B) "###.0"
C) "000.0"
D) "#0.00%"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
10
A block of code is enclosed in a set of

A) braces, { }
B) parentheses, ( )
C) brackets, [ ]
D) double quotes, " "
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
11
If the expression on the left side of the && operator is false, the expression on the right side will not be checked.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following strings could be passed to the DecimalFormat constructor to display 12.78 as 12.8%?

A) "##0.0%"
B) "###.##%"
C) "000.0%"
D) "#0.00%"
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
13
When two strings are compared using the String class's compareTo method, the comparison is not case sensitive.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
14
Unicode is an international encoding system that is extensive enough to represent all the characters of all the world's alphabets.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
15
A random number, created as an object of the Random class, is always an integer.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
16
In a switch statement, if two different values for the CaseExpression would result in the same code being executed, you must have two copies of the code, one after each CaseExpression.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
17
All it takes for an OR expression to be true is for one of the subexpressions to be true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
18
An important style rule that should be used when writing if statements is to write the conditionally executed statement on the line after the if statement.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
19
If str1 and str2 are both String objects, which of the following expressions will correctly determine whether or not they are equal?

A) str1 = str2
B) str1 && str2
C) str1.equals(str2)
D) str1 += str2
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
20
The if-else statement will execute one group of statements if its boolean expression is true or another group if its boolean expression is false.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
21
Which of the following expressions will generate a random number in the range of 1 through 10?

A) myNumber = randomNumbers.nextInt(10);
B) myNumber = randomNumbers.nextInt(1) + 10;
C) myNumber = randomNumbers.nextInt(11) - 1;
D) myNumber = randomNumbers.nextInt(10) + 1;
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
22
What will be the value of x after the following statements are executed?
int x = 75;
Int y = 60;
If (x > y)
X = x - y;

A) 60
B) 75
C) 15
D) 135
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
23
What will be displayed after the following statements are executed?
int x = 65;
Int y = 55;
If (x >= y)
{
Int ans = x + y;
}
System.out.println(ans);

A) 10
B) 120
C) 100
D) The code contains an error and will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
24
What will be the values of ans, x, and y after the following statements are executed?
int ans = 35, x = 50, y = 50;
If (x >= y)
{
Ans = x + 10;
X -= y;
}
Else
{
Ans = y + 10;
Y += x;
}

A) ans = 60, x = 0, and y = 50
B) ans = 45, x = 50, and y = 0
C) ans = 45, x = 50, and y = 50
D) ans = 60, x = 50, and y = 100
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
25
What will be the value of ans after the following statements are executed?
int x = 40;
Int y = 40;
If (x = y)
Ans = x + 10;

A) 30
B) 80
C) 50
D) The code contains an error and will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
26
The __________ statement is used to create a decision structure which allows a program to have more than one path of execution.

A) block
B) if
C) null
D) flag
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
27
A __________ is a boolean variable that signals when some condition exists in the program.

A) sentinel
B) flag
C) block
D) case
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following statements determines whether the variable temp is within the range of 0 through 100 (inclusive)?

A) if (temp >= 0 && temp <= 100)
B) if (temp > 0 && temp < 100)
C) if (temp >= 0 || temp <= 100)
D) if (temp > 0 || temp < 100)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
29
What will be displayed after the following statements are executed?
int hours = 30;
Double pay, payRate = 10.00;
Pay = hours <= 40 ? hours*payRate : hours*payRate*2.0;
System.out.println(pay);

A) 300.0
B) 600.0
C) 400.0
D) The code contains an error and will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
30
Enclosing a group of statements inside a set of braces creates

A) an expression
B) a block of statements
C) a relational operator
D) a conditional statement
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which of the following expressions determines whether the char variable, chrA, is not equal to the letter 'A'?

A) chrA == 'A'
B) chrA != 'A'
C) chrA || 'A'
D) chrA.notEquals(A)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
32
Java requires that the boolean expression being tested by an if statement be enclosed in

A) a set of parentheses
B) a set of braces
C) a set of double quotes
D) a set of brackets
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
33
What will be the value of discountRate after the following statements are executed?
double discountRate;
Char custType = 'B';
Switch (custType)
{
Case 'A':
DiscountRate = 0.08;
Break;
Case 'B':
DiscountRate = 0.06;
Case 'C':
DiscountRate = 0.04;
Default:
DiscountRate = 0.0;
}

A) 0.08
B) 0.06
C) 0.04
D) 0.0
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
34
What will be the value of discountRate after the following statements are executed?
double discountRate = 0.0;
Int purchase = 100;
If (purchase > 1000)
DiscountRate = 0.05;
Else if (purchase > 750)
DiscountRate = 0.03;
Else if (purchase > 500)
DiscountRate = 0.01;

A) 0.0
B) 0.05
C) 0.03
D) 0.01
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
35
When a character is stored in memory, it is actually the __________ that is stored.

A) Unicode number
B) ASCII code
C) floating-point value
D) letter, symbol, or number
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which of the following expressions will determine whether x is less than or equal to y?

A) x <= y
B) x => y
C) x >= y
D) x =< y
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
37
What will be the value of bonus after the following statements are executed? int bonus, sales = 10000;
If (sales < 5000)
Bonus = 200;
Else if (sales < 7500)
Bonus = 500;
Else if (sales < 10000)
Bonus = 750;
Else if (sales < 20000)
Bonus = 1000;
Else
Bonus = 1250;

A) 750
B) 1250
C) 500
D) 1000
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
38
What will be the value of discountRate after the following statements are executed?
double discountRate = 0.0;
Int purchase = 1250;
Char cust = 'N';
If (purchase > 1000)
If (cust == 'Y')
DiscountRate = 0.05;
Else
DiscountRate = 0.04;
Else if (purchase > 750)
If (cust == 'Y')
DiscountRate = 0.04;
Else
DiscountRate = 0.03;
Else
DiscountRate = 0.0;

A) 0.0
B) 0.04
C) 0.05
D) 0.03
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
39
What will be displayed after the following statements are executed?
int y = 10;
If (y == 10)
{
Int x = 30;
X += y;
System.out.println(x);
}

A) 40
B) 30
C) 20
D) The code contains an error and will not compile.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
40
What will be the value of x after the following statements are executed?
int x = 10;
Switch (x)
{
Case 10:
X += 15;
Case 12:
X -= 5;
Break;
Default:
X *= 3;
}

A) 30
B) 20
C) 25
D) 5
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
41
Select all that apply. Which method of the Random class will return a random number within the range of 0.0 and 1.0?

A) nextDouble()
B) nextLong()
C) nextFloat()
D) nextInt(int n)
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
42
Which of the following statements will create an object from the Random class?

A) randomNumbers() = new Random();
B) Random myNumber = new Random();
C) myNumber = new Random();
D) Random = new randomNumbers();
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.
فتح الحزمة
k this deck
locked card icon
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 42 في هذه المجموعة.