The block of code inside the if-statement is skipped.
It is possible to write ANY computer program using only three basic control structures.
The negation of the boolean expression exp1.
true.
Boolean condition checking.
byte, short, int, or char (and String from JDK7).
It outputs the user's score and grade.
It prints 'Three'.
Use a single sayHello() call in each case and repeat it based on the value input.
Congratulations! You got a pass.
To execute a block of code based on a condition being true.
statement_A is executed.
To execute different actions based on the value input by the user.
It tries to match which case has the same value as the switch expression.
To execute different blocks of code based on the value of the variable 'value'.
if (condition) statement_A else statement_B next_statement;
if (condition) statement; next_statement;
A switch statement is typically used for multiple discrete values, while if-else is used for ranges or conditions.
statement_B is executed.
The grade is set to 'P' and a congratulatory message is printed.
It appears to be a reference or code related to a specific document or course.
switch (expression) { case value1: statement(s); break; case value2: statement(s); break; … default: statement(s); }
If examMark is greater than 89.
True.
The value when the condition is true.
Your score is followed by the actual score.
Yes, by using nested if-statements or combining conditions with logical operators.
Twice.
The result of an expression may be incorrect due to unintended order of operations.
Vocational Training Council.
The statement is executed.
Operators with higher precedence are evaluated before operators with lower precedence.
Yes, the statement itself can be another if-statement.
If the score is greater than or equal to 40.
It combines two boolean expressions and returns false only if both are false.
Your score is 30.
If the score is greater than or equal to 75.
'Your score is 50'.
System.out.println("Your score is " + score);
false.
Three.
sm-lau@vtc.edu.hk.
The user's score.
It assigns true to isEven if num is even, otherwise false.
It evaluates the variable 'value' and executes the corresponding case block.
If the score is greater than or equal to 40.
The condition is 'num % 2 == 0'.
False.
'Your score is 30'.
To enclose multiple statements within the else block.
true.
true.
The statement is skipped.
It proceeds to execute the next_statement.
It returns true only if both boolean expressions are true.
It increments countA by 1 if ch is 'A', otherwise it adds 0.
True, because j==3 is true.
The output will be 'D'.
It prints 'after switch'.
Less than or equal to.
false.
sm-lau@vtc.edu.hk.
if (condition) statement; next_statement;
int.
You got a pass.
To determine a grade based on the score input by the user.
The output will be 'B'.
Congratulations! You got a pass. Your score is 80.
countA is incremented by 1.
char.
false.
if (condition) { // code to execute }
It asks for a score from the user.
The nearest if that has not yet been paired.
False.
It prints 'One' and continues to execute the next case without a break.
They allow for decision-making in code execution.
Not equal to.
The statement is executed.
To execute different parts of code based on the value of a variable.
'after switch'.
Each case must end with a break statement to prevent fall-through.
'Congratulations! Your score is 75'.
To execute a block of code based on a boolean condition.
Either true or false.
score >= 40
A unary operator that negates the value of a boolean expression.
To determine a grade based on the score input by the user.
It affects the outcome of expressions by determining which operations are performed first.
It prints 'One'.
Hello Hello Hello Bye!
The default case will be executed.
A value.
Your score is followed by the actual score.
A pair of curly braces { }.
When j is equal to 3 or n is greater than m.
It stores the absolute value of x into y.
False.
False, because both j>k and j!=3 are false.
true.
The rules that determine the order in which different operators are evaluated in an expression.
Yes, parentheses can override the default precedence rules.
It handles any value that is not 1, 2, or 3, printing 'Invalid value'.
To execute different code blocks based on certain conditions.
To perform a specific action if a condition is true.
The code will not function as intended.
A score of 40 or higher.
It indicates the next line of code to execute after the if-else structure.
You got a pass. Your score is 80.
The negative of x is assigned to y.
false.
It proceeds to execute the next_statement.
The grade is set to 'F'.
To check if a score is passing (40 or above) and print a message accordingly.
An if-else statement.
The program does not print 'Congratulations!' and only shows the score.
The value when the condition is false.
The output will be 'C'.
Binary operators for comparing two values.
It prints 'One', 'Two', and 'Three' due to fall-through behavior.
Invalid value.
The statement(s) starting just under the match are executed until a break statement.
Nothing is executed.
An If statement inside another If statement, allowing for multiple conditions to be checked.
It specifies a block of code to execute if the condition in the if statement is false.
Congratulations! Your score is 60. Your grade is P.
It will print 'Invalid value'.
The program uses a Scanner to read input from the keyboard.
It typically indicates the conclusion or termination of the document.
if (condition_2) statement_2;
java.util.*.
if (condition) { if (condition_2) statement_2; } else statement_C next_statement;
A control structure that executes one block of code if a condition is true and another block if it is false.
System.out.println("Congratulations!");
true.
To evaluate a score and provide feedback based on conditions.
condition ? expression_if_true : expression_if_false.
The default case, if provided, will be executed.
The output will be 'A'.
Yes, multiple cases can be grouped together to execute the same code block.
Your score is 30.
True, because n>m is true.
The output will be 'F'.
score >= 75
It prints 'Three' and then breaks out of the switch statement.
It prevents fall-through by exiting the switch after executing the matched case.
int.
Work hard!
System.out.println("You got a pass.");
false.