Wrapper Classes and Character Methods in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on wrapper classes: primitive types and their wrappers, autoboxing and unboxing, parseInt and valueOf conversions, and Character class methods like isDigit, isLetter and toUpperCase, with output questions and a solved program.

Library classes, especially wrapper classes and the Character class, are a regular source of 1- and 2-mark questions in the ICSE Class 10 board paper. They also appear in programs that check each character of a string. These notes give you every method in the syllabus, with outputs.
What is a wrapper class?
A wrapper class "wraps" a primitive value inside an object, so the value can be used where Java expects an object and so you can use helpful methods such as converting text to numbers. All the wrapper classes are in java.lang.
Primitive Wrapper class
byte Byte
short Short
int Integer
long Long
float Float
double Double
char Character
boolean BooleanOnly two wrapper names differ from their primitive type:int→ Integer andchar→ Character.
Autoboxing and unboxing
- Autoboxing: Java automatically converts a primitive into its wrapper object.
- Unboxing: Java automatically converts a wrapper object back into a primitive.
Integer obj = 25; // autoboxing: int → Integer
int n = obj; // unboxing: Integer → int
Double d = 3.5; // autoboxing
double x = d + 1.5; // unboxing, then addition: 5.0Converting a String to a number
int a = Integer.parseInt("123"); // 123
double b = Double.parseDouble("45.6"); // 45.6
long c = Long.parseLong("9876543210"); // 9876543210
Integer d = Integer.valueOf("50"); // an Integer object holding 50parseXxx()returns a primitive.valueOf()returns a wrapper object.- If the string is not a valid number, for example
Integer.parseInt("12a"), Java throws a NumberFormatException.
Converting a number to a String
String s1 = Integer.toString(75); // "75"
String s2 = String.valueOf(3.14); // "3.14"
String s3 = 42 + ""; // "42" (a quick trick)Character class methods
All of these are static, so you call them as Character.method(ch).
isLetter(ch): true if ch is a letter.Character.isLetter('a')is true.isDigit(ch): true if ch is a digit 0–9.Character.isDigit('7')is true.isLetterOrDigit(ch): true for a letter or a digit.Character.isLetterOrDigit('#')is false.isWhitespace(ch): true for a space, tab or newline.Character.isWhitespace(' ')is true.isUpperCase(ch):Character.isUpperCase('Q')is true.isLowerCase(ch):Character.isLowerCase('Q')is false.toUpperCase(ch):Character.toUpperCase('b')returns 'B'.toLowerCase(ch):Character.toLowerCase('B')returns 'b'.
toUpperCaseandtoLowerCasereturn a char. Characters that are not letters are returned unchanged:Character.toUpperCase('5')is'5'.
Output questions
Q1. System.out.println(Integer.parseInt("20") + Integer.parseInt("30"));
Answer: 50. Both strings are converted to int and then added.
Q2. System.out.println("20" + 30);
Answer: 2030. This is string joining, not addition.
Q3. char c = 'd'; System.out.println(Character.toUpperCase(c) + 1);
Answer: 69. toUpperCase gives 'D', whose code is 68. Adding 1 promotes it to int, so the result is 69.
Q4. System.out.println(Character.isDigit('5') && Character.isLetter('5'));
Answer: false. '5' is a digit but not a letter.
Solved program: count the character types in a string
import java.util.Scanner;
class CharCount {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print("Enter a string: ");
String s = sc.nextLine();
int upper = 0, lower = 0, digits = 0, spaces = 0, others = 0;
for (int i = 0; i < s.length(); i++) {
char ch = s.charAt(i);
if (Character.isUpperCase(ch)) upper++;
else if (Character.isLowerCase(ch)) lower++;
else if (Character.isDigit(ch)) digits++;
else if (Character.isWhitespace(ch)) spaces++;
else others++;
}
System.out.println("Uppercase: " + upper + ", Lowercase: " + lower
+ ", Digits: " + digits + ", Spaces: " + spaces + ", Others: " + others);
}
}Sample run: for "ICSE Exam 2027!", the output is Uppercase: 5, Lowercase: 3, Digits: 4, Spaces: 2, Others: 1.
Practice questions
- Name the wrapper classes of
charandboolean. - What is the difference between
Integer.parseInt()andInteger.valueOf()? - What exception does
Double.parseDouble("abc")throw?
Answers:
- Character and Boolean.
parseIntreturns a primitive int, whilevalueOfreturns an Integer object.- NumberFormatException.
Revise these methods alongside our 10 most important String programs for ICSE Class 10.
Related Posts
Continue learning with these related articles
Sum of First n Natural Numbers in Java (Loop and Formula)
Find the sum of the first n natural numbers in Java with a for loop, a while loop and the formula n(n + 1)/2, with a dry run and the sums of even numbers, odd numbers, squares and cubes.
Prime Number Program in Java: Check a Number and Print Primes in a Range
Check whether a number is prime in Java by counting its factors, a faster square-root method with isPrime(), and a program that prints all prime numbers in a range.

Encapsulation, Access Specifiers and Scope of Variables in Java for ICSE Class 10
ICSE Class 10 Computer Applications notes on encapsulation: private, default, protected and public access, data hiding with getter and setter methods, instance vs static (class) variables, local variables and scope, with a solved BankAccount program.