Deck 3: Control Statements
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/39
العب
ملء الشاشة (f)
Deck 3: Control Statements
1
What is output by the following Java code segment?
Int temp = 180;
If (temp > 90)
{
System.out.println("This porridge is too hot.");
// cool down
Temp = temp - (temp > 150 ? 100 : 20);
}
Else
{
If (temp < 70)
{
System.out.println("This porridge is too cold.");
// warm up
Temp = temp + (temp < 50 ? 30 : 20);
}
}
If (temp == 80)
System.out.println("This porridge is just right!");
A) This porridge is too hot.
B) This porridge is too cold. This porridge is just right!
C) This porridge is just right!
D) None of the above.
Int temp = 180;
If (temp > 90)
{
System.out.println("This porridge is too hot.");
// cool down
Temp = temp - (temp > 150 ? 100 : 20);
}
Else
{
If (temp < 70)
{
System.out.println("This porridge is too cold.");
// warm up
Temp = temp + (temp < 50 ? 30 : 20);
}
}
If (temp == 80)
System.out.println("This porridge is just right!");
A) This porridge is too hot.
B) This porridge is too cold. This porridge is just right!
C) This porridge is just right!
D) None of the above.
D
2
Which of the following is a double-selection control statement?
A) do…while
B) for
C) if…else
D) if
A) do…while
B) for
C) if…else
D) if
C
3
Which statement is false?
A) Unless directed otherwise, the computer executes Java statements one after the other in the order in which they're written.
B) Activity diagrams normally show the Java code that implements the activity.
C) Like pseudocode, activity diagrams help programmers develop and represent algorithms.
D) The arrows in the activity diagram represent transitions, which indicate the order in which the actions represented by the action states occur.
A) Unless directed otherwise, the computer executes Java statements one after the other in the order in which they're written.
B) Activity diagrams normally show the Java code that implements the activity.
C) Like pseudocode, activity diagrams help programmers develop and represent algorithms.
D) The arrows in the activity diagram represent transitions, which indicate the order in which the actions represented by the action states occur.
B
4
Which of the following is not a Java keyword?
A) do
B) next
C) while
D) for
A) do
B) next
C) while
D) for
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
5
Which of the following is true?
A) Pseudocode is used to describe an algorithm.
B) Pseudocode is not an actual computer programming language.
C) Pseudocode is used to describe executable statements that will eventually be translated by the programmer into a program.
D) All of the above.
A) Pseudocode is used to describe an algorithm.
B) Pseudocode is not an actual computer programming language.
C) Pseudocode is used to describe executable statements that will eventually be translated by the programmer into a program.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
6
Which of the following is not an algorithm?
A) A recipe.
B) Operating instructions.
C) Textbook index.
D) Shampoo instructions (lather, rinse, repeat).
A) A recipe.
B) Operating instructions.
C) Textbook index.
D) Shampoo instructions (lather, rinse, repeat).
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
7
What is output by the following Java code segment?
Int temp = 180;
While (temp != 80)
{
If (temp > 90)
{
System.out.print("This porridge is too hot! ");
// cool down
Temp = temp - (temp > 150 ? 100 : 20);
}
Else
{
If (temp < 70)
{
System.out.print(
"This porridge is too cold! ");
// warm up
Temp = temp + (temp < 50 ? 30 : 20);
}
}
}
If (temp == 80)
System.out.println("This porridge is just right!");
A) This porridge is too cold! This porridge is just right!
B) This porridge is too hot! This porridge is just right!
C) This porridge is just right!
D) None of the above.
Int temp = 180;
While (temp != 80)
{
If (temp > 90)
{
System.out.print("This porridge is too hot! ");
// cool down
Temp = temp - (temp > 150 ? 100 : 20);
}
Else
{
If (temp < 70)
{
System.out.print(
"This porridge is too cold! ");
// warm up
Temp = temp + (temp < 50 ? 30 : 20);
}
}
}
If (temp == 80)
System.out.println("This porridge is just right!");
A) This porridge is too cold! This porridge is just right!
B) This porridge is too hot! This porridge is just right!
C) This porridge is just right!
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
8
Which of the following is not represented graphically in activity diagrams for control structures?
A) Transition arrow.
B) Attribute.
C) Action state.
D) Decision symbol.
A) Transition arrow.
B) Attribute.
C) Action state.
D) Decision symbol.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
9
Which of the following is not a benefit of "goto-less programming"?
A) Easier to debug and modify
B) Shorter
C) Clearer
D) More likely to be bug free
A) Easier to debug and modify
B) Shorter
C) Clearer
D) More likely to be bug free
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
10
Which of the following would not be used to clarify a dangling-else?
A) Indentation.
B) Parentheses ().
C) Braces {}.
D) Comment //.
A) Indentation.
B) Parentheses ().
C) Braces {}.
D) Comment //.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
11
Which of the following statements is true?
A) Both syntax errors and logic errors are caught by the compiler.
B) Both syntax errors and logic errors have effects at execution time.
C) Syntax errors are caught by the compiler. Logic errors have effects at execution time.
D) Logic errors are caught by the compiler. Syntax errors have effects at execution time.
A) Both syntax errors and logic errors are caught by the compiler.
B) Both syntax errors and logic errors have effects at execution time.
C) Syntax errors are caught by the compiler. Logic errors have effects at execution time.
D) Logic errors are caught by the compiler. Syntax errors have effects at execution time.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
12
Which of the following is the shape of an action-state symbol?
A) Diamond.
B) Circle.
C) Rectangle with left and right sides replaced with arcs curving outward.
D) Rounded rectangle.
A) Diamond.
B) Circle.
C) Rectangle with left and right sides replaced with arcs curving outward.
D) Rounded rectangle.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
13
The empty statement is denoted by what symbol?
A) Semicolon ;
B) Parentheses ()
C) Braces {}
D) Colon :
A) Semicolon ;
B) Parentheses ()
C) Braces {}
D) Colon :
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
14
Which of the following is not a control structure:
A) Sequence structure.
B) Selection structure.
C) Repetition structure.
D) Declaration structure.
A) Sequence structure.
B) Selection structure.
C) Repetition structure.
D) Declaration structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
15
Which of the following statements about the conditional operator (?:) is false?
A) The conditional operator is a ternary operator, meaning that it takes three operands.
B) The first operand is a boolean expression.
C) The second operand is the result value if the condition evaluates to false.
D) The second operand is the result value if the condition evaluates to true.
A) The conditional operator is a ternary operator, meaning that it takes three operands.
B) The first operand is a boolean expression.
C) The second operand is the result value if the condition evaluates to false.
D) The second operand is the result value if the condition evaluates to true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
16
In an activity diagram, the merge symbol has the same shape as what other symbol?
A) Decision symbol.
B) Action symbol.
C) Transition arrows.
D) Initial state.
A) Decision symbol.
B) Action symbol.
C) Transition arrows.
D) Initial state.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
17
What is output by the following Java code segment?
Int temp = 200;
If (temp > 90)
System.out.println("This porridge is too hot.");
If (temp < 70)
System.out.println("This porridge is too cold.");
If (temp == 80)
System.out.println("This porridge is just right!");
A) This porridge is too hot.
B) This porridge is too cold.
C) This porridge is just right!
D) None of the above.
Int temp = 200;
If (temp > 90)
System.out.println("This porridge is too hot.");
If (temp < 70)
System.out.println("This porridge is too cold.");
If (temp == 80)
System.out.println("This porridge is just right!");
A) This porridge is too hot.
B) This porridge is too cold.
C) This porridge is just right!
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
18
Which of the following is not an error (either a syntax error or a logic error)?
A) Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false.
B) Spelling a keyword (such as while or if) with a capitalized first letter.
C) Using a condition for a while statement that is initially false.
D) An infinite loop.
A) Neglecting to include an action in the body of a while statement that will eventually cause the condition to become false.
B) Spelling a keyword (such as while or if) with a capitalized first letter.
C) Using a condition for a while statement that is initially false.
D) An infinite loop.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
19
Counter-controlled repetition is also known as:
A) Definite repetition
B) Indefinite repetition
C) Multiple-repetition structure
D) Double-repetition structure
A) Definite repetition
B) Indefinite repetition
C) Multiple-repetition structure
D) Double-repetition structure
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
20
A decision symbol in an activity diagram takes the shape of a ________.
A) Diamond.
B) Rectangle.
C) Circle.
D) Triangle.
A) Diamond.
B) Rectangle.
C) Circle.
D) Triangle.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
21
In Java graphics, coordinate units are measured in ________.
A) pixlets.
B) pixels.
C) points.
D) pikels.
A) pixlets.
B) pixels.
C) points.
D) pikels.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
22
Java is considered a strongly typed language because:
A) The primitive types in Java are portable across all computer platforms that support Java.
B) Java requires all variables to have a type before they can be used in a program.
C) Instance variables of the primitive types are automatically assigned a default value.
D) All of the above.
A) The primitive types in Java are portable across all computer platforms that support Java.
B) Java requires all variables to have a type before they can be used in a program.
C) Instance variables of the primitive types are automatically assigned a default value.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
23
How many times is the body of the loop below executed?
Int counter = 1;
While (counter > 20)
{
// body of loop
Counter = counter - 1;
} // end while
A) 19.
B) 20.
C) 21.
D) 0.
Int counter = 1;
While (counter > 20)
{
// body of loop
Counter = counter - 1;
} // end while
A) 19.
B) 20.
C) 21.
D) 0.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
24
Sentinel-controlled repetition is also known as ________.
A) Definite repetition
B) Indefinite repetition
C) Multiple repetition
D) Double repetition
A) Definite repetition
B) Indefinite repetition
C) Multiple repetition
D) Double repetition
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
25
Which primitive type can hold the largest value?
A) int
B) long
C) float
D) double
A) int
B) long
C) float
D) double
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
26
What does the expression x %= 10 do?
A) Adds 10 to the value of x, and stores the result in x.
B) Divides x by 10 and stores the remainder in x.
C) Divides x by 10 and stores the integer result in x.
D) None of the above.
A) Adds 10 to the value of x, and stores the result in x.
B) Divides x by 10 and stores the remainder in x.
C) Divides x by 10 and stores the integer result in x.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
27
Where can local variables declared within a method's body be used?
A) Only in that method between the line in which they were declared and the closing brace of that method.
B) Same as (a), but not within while or if statements.
C) Only within while or if statements within the method in which they were declared.
D) Anywhere within the class.
A) Only in that method between the line in which they were declared and the closing brace of that method.
B) Same as (a), but not within while or if statements.
C) Only within while or if statements within the method in which they were declared.
D) Anywhere within the class.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
28
Which of the following is not a common name for one of the three phases that a program often can be split into using pseudocode?
A) Termination phase
B) Initialization phase
C) Processing phase
D) Action phase
A) Termination phase
B) Initialization phase
C) Processing phase
D) Action phase
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
29
Which of the following is not a primitive type?
A) char
B) float
C) String
D) int
A) char
B) float
C) String
D) int
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
30
Keyword ________ indicates the inheritance relationship.
A) extends
B) inherits
C) super
D) parent
A) extends
B) inherits
C) super
D) parent
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
31
Which statement is true?
A) Dividing two integers results in integer division.
B) With integer division, any fractional part of the calculation is lost.
C) With integer division, any fractional part of the calculation is truncated.
D) All of the above.
A) Dividing two integers results in integer division.
B) With integer division, any fractional part of the calculation is lost.
C) With integer division, any fractional part of the calculation is truncated.
D) All of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
32
Which of the following code segments does not increment val by 3:
A) val += 3;
B) val = val + 1; val = val + 1;
Val = val + 1;
C) c = 3; val = val + (c == 3 ? 2 : 3);
D) All of the above increment val by 3.
A) val += 3;
B) val = val + 1; val = val + 1;
Val = val + 1;
C) c = 3; val = val + (c == 3 ? 2 : 3);
D) All of the above increment val by 3.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
33
What is the size in bits of an int?
A) 8
B) 16
C) 32
D) 64
A) 8
B) 16
C) 32
D) 64
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
34
What is the result value of c at the end of the following code segment?
Int c = 8;
C++;
++c;
C %= 5;
A) 0.
B) 1.
C) 3.
D) None of the above.
Int c = 8;
C++;
++c;
C %= 5;
A) 0.
B) 1.
C) 3.
D) None of the above.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
35
In an expression containing values of the types int and double, the ________ values are ________ to ________ values for use in the expression.
A) int, promoted, double.
B) int, demoted, double.
C) double, promoted, int.
D) double, demoted, int.
A) int, promoted, double.
B) int, demoted, double.
C) double, promoted, int.
D) double, demoted, int.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
36
Which of the following terms is not used to refer to a sentinel value that breaks out of a while loop?
A) signal value.
B) maximum value.
C) dummy value.
D) flag value.
A) signal value.
B) maximum value.
C) dummy value.
D) flag value.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
37
Which of the following operators associates from left to right?
A) =
B) ?:
C) %=
D) /
A) =
B) ?:
C) %=
D) /
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
38
Which of the following statements is false?
A) To ensure that the operands in a mixed-type expression are of the same type, Java performs implicit conversion on selected operands.
B) Cast operators are unary operators.
C) Cast operators associate from right to left and are one level lower in precedence than the multiplicative operators.
D) Cast operators are formed by placing parentheses around the name of a type.
A) To ensure that the operands in a mixed-type expression are of the same type, Java performs implicit conversion on selected operands.
B) Cast operators are unary operators.
C) Cast operators associate from right to left and are one level lower in precedence than the multiplicative operators.
D) Cast operators are formed by placing parentheses around the name of a type.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
39
Local variables must be ________.
A) initialized when they're declared.
B) initialized before their values are used in an expression.
C) declared and initialized in two steps.
D) declared at the top of the method's body.
A) initialized when they're declared.
B) initialized before their values are used in an expression.
C) declared and initialized in two steps.
D) declared at the top of the method's body.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck