Short answerModerate2 marks
(i) int res = 'A'; What is the value of res? (ii) Name the package that contains wrapper classes.
Topic: char to int and packages
Previous-year question practice database
Answer
Exam answer
(i) res = 65 (ii) java.lang
Explanation
(i) Assigning a char to an int stores its Unicode value. 'A' is 65. Fix the anchors: 'A' = 65, 'a' = 97, '0' = 48 — almost every char question in this paper is answered from these three. (ii) All the wrapper classes — Integer, Character, Double, Boolean and the rest — belong to java.lang, along with String and Math. java.lang is imported automatically, which is why no import statement is ever needed for them. Careful: some published keys give java.util for this, which is wrong — java.util holds Scanner and the collection classes.
More from Revision Tour I
The full form of JVM is:2026Which of the following occupies 2 bytes of storage?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:2025