Chapter 6: Conditional Statements in BlueJ
Section A: Multiple Choice Questions (30 Marks)
1. Selection statements in programming are often referred to as:
2. In a sequential construct, how are statements executed?
3. What happens if the condition in an `if` statement evaluates to false?
4. Which control structure is used when either of two different actions is to be performed depending on the conditional expression?
5. Which structure provides a compact way to check multiple conditions sequentially where each condition has a block of statements?
6. The test condition in an `if` statement must return which data type value?
7. Which operator is used to check equality between two values in conditional expressions?
8. Which operator represents logical AND in Java/BlueJ?
9. What is the symbol for logical OR operator in Java?
10. Which statement executes when the condition in an `if...else` construct evaluates to false?
11. What is the value of `a % 2` when `a = 15`?
12. How do you check if a number `num` is divisible by 5?
13. A Buzz number is defined as a number that ends with 7 or is divisible by:
14. Which expression checks if `num` ends with 7?
15. What condition determines if a voting candidate is eligible (age >= 18)?
16. In an `if...else if...else` ladder, how many `else` blocks can exist at the end?
17. Which operator evaluates to true if both conditions are true?
18. Which statement is used to execute a block of statements if a given condition is true, otherwise skip it?
19. What result is obtained for conditional check `10 != 5`?
20. To check if a character `ch` is uppercase, which range check is correct?
21. If `length == breadth`, what geometric shape is formed?
22. Which expression checks if `a` is greater than both `b` and `c`?
23. What will `if (score >= 80)` output when `score = 85`?
24. Which condition checks if number `n` is fully divisible by number `d`?
25. What is the logical NOT operator in Java?
26. In an `if (a > b)` construct, what surrounds the condition `a > b`?
27. What is the output of condition `!(5 > 2)`?
28. In Java, curly braces `{}` are used to enclose:
29. If `temp = 0`, what does `if (temp < 0)` evaluate to?
30. Which control structure helps a program choose between two or more paths based on a condition?
Section B: Assertion & Reason Questions (30 Marks)
Directions: Choose the correct option:
- A: Both Assertion (A) and Reason (R) are true, and Reason (R) is the correct explanation.
- B: Both Assertion (A) and Reason (R) are true, but Reason (R) is NOT the correct explanation.
- C: Assertion (A) is true, but Reason (R) is false.
- D: Assertion (A) is false, but Reason (R) is true.
31. Assertion (A): Selection statements are also known as decision-making statements.
Reason (R): They transfer program control to a specific statement depending on the boolean result of a conditional expression.
32. Assertion (A): In sequential execution, statements can skip directly to the end based on user input.
Reason (R): Sequential constructs execute statements strictly one after the other with no branching.
33. Assertion (A): The condition in an `if` statement must evaluate to a boolean value.
Reason (R): Java requires boolean conditions (`true` or `false`) to determine execution flow.
34. Assertion (A): All conditions in an `if...else if...else` ladder are evaluated even if the first condition is true.
Reason (R): The ladder skips remaining checks once a true condition is encountered and its block executed.
35. Assertion (A): Modulus operator `%` returns the remainder of integer division.
Reason (R): `num % 2 == 0` evaluates to true for all even numbers.
36. Assertion (A): The relational operator `==` assigns a value to a variable.
Reason (R): `==` checks equality, whereas `=` is the assignment operator in Java.
37. Assertion (A): An `if` statement can exist without an accompanying `else` block.
Reason (R): The `else` block is optional in simple `if` selection structures.
38. Assertion (A): Logical AND (`&&`) returns true if at least one operand is true.
Reason (R): `&&` requires both expressions to be true simultaneously.
39. Assertion (A): Logical OR (`||`) returns true if either condition is true.
Reason (R): A Buzz number condition uses `||` because ending in 7 OR being divisible by 7 makes it valid.
40. Assertion (A): A number ending in 7 gives `num % 10 == 7`.
Reason (R): Modulo 10 extracts the last digit (units place) of an integer.
41. Assertion (A): `age >= 18` checks if a person is eligible to vote.
Reason (R): In India, citizens aged 18 and above possess voting rights.
42. Assertion (A): `length == breadth` tests if a rectangle is a square.
Reason (R): A square is a special rectangle with all four equal sides.
43. Assertion (A): The condition `if (a > b && a > c)` finds if `a` is the smallest of three numbers.
Reason (R): Greater-than operator (`>`) combined with `&&` ensures `a` is strictly larger than both `b` and `c`.
44. Assertion (A): Multiple `if` statements check conditions independently.
Reason (R): Independent `if` statements do not bypass subsequent checks like `if...else if` does.
45. Assertion (A): Nested `if` means placing an `if` statement inside another `if` block.
Reason (R): Inner `if` statements execute only when the outer `if` condition evaluates to true.
46. Assertion (A): `ch >= 'A' && ch <= 'Z'` verifies an uppercase alphabet.
Reason (R): Uppercase letters in Java/ASCII lie sequentially between 'A' and 'Z'.
47. Assertion (A): The expression `a % b == 0` checks if `a` is fully divisible by `b`.
Reason (R): Zero remainder indicates exact divisibility.
48. Assertion (A): Logical NOT `!` flips `true` to `false`.
Reason (R): Unary NOT operator reverses the logical state of its operand.
49. Assertion (A): BlueJ allows writing and executing Java programs.
Reason (R): BlueJ is an Integrated Development Environment (IDE) designed for learning Java.
50. Assertion (A): Indentation inside `if` blocks is strictly mandatory for BlueJ to compile.
Reason (R): Java uses curly braces `{}` to define blocks; indentation improves human readability.
51. Assertion (A): `1 = 1` is valid syntax inside an `if` condition.
Reason (R): `1 == 1` is required because `=` assigns values rather than comparing them.
52. Assertion (A): Non-zero numbers are automatically treated as true in Java conditional checks.
Reason (R): Java strict typing enforces explicit boolean expressions inside `if(...)` statements.
53. Assertion (A): `if (score >= 40) result = "Pass"; else result = "Fail";` is valid.
Reason (R): Single-statement `if-else` blocks do not strictly require curly braces `{}`.
54. Assertion (A): Checking 3 ages to find the oldest requires comparing pairs using relational operators.
Reason (R): Logical operators combine pair comparisons into single conditional expressions.
55. Assertion (A): An `else` block can exist independently without an `if` statement.
Reason (R): `else` defines alternative execution strictly paired with a preceding `if` condition.
56. Assertion (A): `a == b` and `a != b` produce opposite boolean results for any values.
Reason (R): `!=` represents logical NOT equal to operator.
57. Assertion (A): `if...else if` ladders are useful for grading systems.
Reason (R): Marks fall into continuous ranges requiring sequential condition testing.
58. Assertion (A): Executing a program with static inputs tests all conditional branches.
Reason (R): Testing different branches requires providing varied sample inputs that trigger each path.
59. Assertion (A): Real-life situations like traffic light signals utilize conditional decision logic.
Reason (R): Action rules depend on traffic light color: If red stop, else go.
60. Assertion (A): Logical operators simplify complex decision conditions.
Reason (R): They allow combining multiple sub-conditions without writing deep nested `if` statements.
Section C: Visual & Scenario Based Questions (10 Marks)
61. Identify the logic rule visual:
If today is Sunday ➔ sleep till 9 am
Else ➔ wake up at 6:30 am
What time will you wake up on Wednesday?
62. Observe the real-life decision visual:
If homework complete ➔ go out to play
Else ➔ finish homework first
If your homework is incomplete, what action should you take?
63. Look at the traffic light rule visual:
If traffic light is red ➔ stop
Else ➔ go
What do you do when the traffic light turns green?
64. Scenario Visual: Rashmi writes code to check temperature:
if (temp < 0) { System.out.println("Freezing point"); }
What is printed if `temp` equals `-5`?
65. Scenario Visual: Mohit designs game bonus logic:
if (score > 50) { bonus = 10; }
What bonus is awarded if `score` equals `65`?
66. Identify the reward points lookup table visual:
Points Range 81-100 ➔ Certificate + Trophy
Points Range 61-80 ➔ Certificate Only
If a student earns 85 points, what reward is granted?
67. Observe the weather decision rule:
If raining ➔ take umbrella
Else ➔ wear sunglasses
If the sky is clear and sunny today, what action is selected?
68. Identify the grading rule visual:
If score > 80 ➔ get chocolate
Else ➔ get smiley sticker
What reward do you get if you score 85?
69. Look at the code snippet layout:
if (a % 2 == 0) System.out.println("Even");
else System.out.println("Odd");
If `a = 14`, what is displayed?
70. Identify the mapping chart visual:
Input: 1 ➔ Monday
Input: 7 ➔ Sunday
Which conditional structure converts numbers 1 to 7 into weekday names?
No comments:
Post a Comment