Deck 4: Control Statements: Assignment, and Operators
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
سؤال
فتح الحزمة
قم بالتسجيل لفتح البطاقات في هذه المجموعة!
Unlock Deck
Unlock Deck
1/39
العب
ملء الشاشة (f)
Deck 4: Control Statements: Assignment, and Operators
1
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.
C
2
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.
B
3
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.
This porridge is too hot! This porridge is just right!
4
Which of the following statements is false?
A) You should not call methods from constructors.
B) Nested if statements can be useful for validating values.
C) Logical operators can express nested if statements more concisely.
D) One problem with calling methods from constructors is that it can lead to duplicated validation code.
A) You should not call methods from constructors.
B) Nested if statements can be useful for validating values.
C) Logical operators can express nested if statements more concisely.
D) One problem with calling methods from constructors is that it can lead to duplicated validation code.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
5
Counter-controlled iteration is also known as:
A) Definite iteration
B) Indefinite iteration
C) Multiple-iteration structure
D) Double-iteration structure
A) Definite iteration
B) Indefinite iteration
C) Multiple-iteration structure
D) Double-iteration structure
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 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
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
8
Which of the following is not a control structure:
A) Sequence structure.
B) Selection structure.
C) Iteration structure.
D) Declaration structure.
A) Sequence structure.
B) Selection structure.
C) Iteration structure.
D) Declaration structure.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
9
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
10
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
11
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
12
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
13
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
14
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
15
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
16
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
17
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
18
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
19
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.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
20
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
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
21
Sentinel-controlled iteration is also known as:
A) Definite iteration.
B) Indefinite iteration.
C) Multiple iteration.
D) Double iteration.
A) Definite iteration.
B) Indefinite iteration.
C) Multiple iteration.
D) Double iteration.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
22
Which of the following statements is true?
A) A while statement cannot be nested inside another while statement.
B) An if statement cannot be nested inside another if statement.
C) A while statement cannot be nested inside an if statement.
D) None of the above is true.
A) A while statement cannot be nested inside another while statement.
B) An if statement cannot be nested inside another if statement.
C) A while statement cannot be nested inside an if statement.
D) None of the above is true.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 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;
}
A) 19.
B) 20.
C) 21.
D) 0.
int counter = 1;
While (counter > 20) {
// body of loop
Counter = counter - 1;
}
A) 19.
B) 20.
C) 21.
D) 0.
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
24
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
25
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
26
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
27
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
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
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
30
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
31
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
32
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
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
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
35
Which of the following segments is a proper way to call the method readData four times?
A) double k = 0.0;
While (k != 4) {
ReadData();
K = k + 1;
}
B) int i = 0;
While (i <= 4) {
ReadData();
I = i + 1;
}
C) int i = 0;
While (i < 4) {
ReadData();
}
D) int i = 0;
While (i < 4) {
ReadData();
I = i + 1;
}
A) double k = 0.0;
While (k != 4) {
ReadData();
K = k + 1;
}
B) int i = 0;
While (i <= 4) {
ReadData();
I = i + 1;
}
C) int i = 0;
While (i < 4) {
ReadData();
}
D) int i = 0;
While (i < 4) {
ReadData();
I = i + 1;
}
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
36
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
37
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
38
Which of the following operators associates from left to right?
A) =
B) ?:
C) %=
D) /
A) =
B) ?:
C) %=
D) /
فتح الحزمة
افتح القفل للوصول البطاقات البالغ عددها 39 في هذه المجموعة.
فتح الحزمة
k this deck
39
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