MCQModerate1 mark
1
Choose the correct answers to the questions from the given options. (Do not copy the questions, write only the correct answers.)
Which of the following occupies 2 bytes of storage?
Topic: Memory occupied by literals
Previous-year question practice database
Try it
Pick an option and check your answer. The full worked answer is below either way.
Answer
Exam answer
(d) \\.
Explanation
Test each literal by its type. 25 is an int literal (4 bytes). "AM" is a String of two characters, which is an object, not a 2-byte primitive. 35.2 is a double literal (8 bytes). \\ is the escape sequence for a single backslash character — one char, and a char in Java occupies exactly 2 bytes because it stores a Unicode value. The trap is thinking an escape sequence is two characters; it is written with two symbols but stores one.
In words
\\.
More from Revision Tour I
The full form of JVM is:2026In a statement c = c + (x * d + e); which variable is an accumulator?2026Assertion (A): The result of the Java expression 3 + 7/2 is 6.
Reason (R): According to the hierarchy of operators in Java, addition is done first followed by division.2026Evaluate the Java expression:
x = a * b % (++c) + (++a) + (--b);
if a = 7, b = 8, c = 22026System.out.println('Z' + 32); will display:2025The output of 42/6%2 is:2025