- Ajava.util
- B java.lang
- Cjava.awt
- Djava.io
ar.length()ar[].lengthar.length() - 1ar.length - 1
Time Taken:
Correct Answer:
Wrong Answer:
Percentage: %
The correct answer is:
(b) java.lang
The Character class is part of the java.lang package, which is automatically imported in every Java program. It provides various methods for character manipulation, such as isDigit(), isLetter(), and toUpperCase().
The correct answer is:
(d) 154
In the expression:
System.out.println('Z' + 32);
The character 'Z' has an ASCII value of 90.
The integer 32 is added to it:
90 + 32 = 122.
Since both 'Z' (char) and 32 (int) are involved in an arithmetic operation, 'Z' is promoted to an integer before addition.
The result is 122, which is the ASCII value of 'z', but since no type casting is done, it prints the integer 122 instead of the character 'z'.
So, the correct answer should be (c) 122, not (d) 154. Please verify your answer choices.
Each double in Java occupies 8 bytes, and the array contains 4 elements.
Total memory occupied = 8 bytes × 4 = 32 bytes
Correct answer: (d) 32
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 ✅
Barcode Scanner is located at row index 1 and column index 1 in the given 2D array P[2][3].
✅ Correct Answer: (a) P[1][1]
(c) Game is a class and cricket is an object
Explanation: Game is the class, new Game(); creates an object named cricket.
c) for
Explanation: The for loop is used for a fixed number of repetitions (10 times).
(d) ar.length - 1
Explanation: The last index of an array is always length - 1 (since array indices start at 0).
(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!)