- A1
- B10
- C2
- D00
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
The output of \( 42 \div 6 \mod 2 \) is:
Let's break down the expression step by step:
\[ 42 \div 6 \mod 2 \]
\[ 42 \div 6 = 7 \]
\[ 7 \mod 2 \]
The modulus operator (\%) gives the remainder when dividing 7 by 2.
\[ 7 \div 2 = 3 \text{ remainder } 1 \]
So,
\[ 7 \mod 2 = 1 \]
(a) 1 ✅
Let's check the correct infinite loop:
for(int i=2; i!=0; i-=3)
Step 1: i = 2 (Condition i != 0 is true → executes)
Step 2: i -= 3 (Now i = -1)
Step 3: i != 0? Still true → executes again
Step 4: i -= 3 (Now i = -4)
Step 5: i != 0? Still true → executes again...
This never stops because i will always be != 0.
✅ Correct Answer: (b) for(int i=2; i!=0; i-=3) (Infinite Loop)
(b) -4
Explanation: Math.min(-5, -4) → -5, then Math.max(-7, -5) → -5 (Correct answer: -5).
(c) Game is a class and cricket is an object
Explanation: Game is the class, new Game(); creates an object named cricket.
(a) public
Explanation: A post office is accessible to everyone, similar to public access specifier.
(a) Both (A) and (R) are true, and (R) is a correct explanation of (A)
Explanation: The break statement prevents fall-through in a switch case by stopping execution after a case is matched.
c) for
Explanation: The for loop is used for a fixed number of repetitions (10 times).
(a) Both (A) and (R) are true, and (R) is a correct explanation of (A)
Explanation: A clock's hour and minute hands resemble nested loops, where the minute hand completes a full cycle for each hour hand movement.
(c) Double.parseDouble("25")
Explanation: The parseDouble() method converts a String to a double. The correct syntax is Double.parseDouble("25").
The compareTo() method compares two strings lexicographically.
"ANGER".compareTo("ANGEL") compares characters at each position.
'R' - 'L' = 82 - 76 = 6, so the result is 6.
Since "ANGER" comes after "ANGEL" lexicographically, the result should be positive.
Correct answer: (c) 6 (Correction from previous choice!)