Library Classes ICSE Class 10: Wrapper Classes and Character Methods
Updated 14 October 2026 · Fact-checked
Library classes are ready-made Java classes. Each primitive type has a wrapper class in java.lang (Integer for int, Double for double, Character for char and so on). ICSE Class 10 tests parseInt, parseLong, parseFloat and parseDouble, the Character methods isDigit, isLetter, isLetterOrDigit, isLowerCase, isUpperCase, isWhitespace, toLowerCase and toUpperCase, and autoboxing and unboxing.
What Library Classes is about
Wrapper class methods turn up in Section A every year and are expected in Section B string programs. In 2024 the board asked for the method that checks whether a character is a letter or digit, the difference between boxing and unboxing, and the package that holds wrapper classes; in 2025 the package of Character methods, the correct call to convert "25" to 25.0, and a Section B 'Super string' program that had to use Character methods. Examiners noted that candidates compared characters with ranges such as ch >= 'A' && ch <= 'Z' instead of using the Character methods asked for.
The syllabus asks for an introduction to wrapper classes, the twelve listed methods and their use with numeric and character data, autoboxing and unboxing with simple examples, and a class as a composite type distinct from primitive types.
Weightage: CISCE publishes no chapter weightage. Section A (40 marks) is compulsory: 1-mark MCQs and 2-mark short answers including output and error questions; in Section B you answer any four of six 15-mark programming questions written in Java.Source: CISCE ICSE Computer Applications (661) specimen paper structure for 2027
Key concepts
- Wrapper classes and composite types
A wrapper class wraps a primitive value inside an object, so that it can be treated as an object and has useful methods. Every primitive type has one, all in java.lang:
byte - Byte, short - Short, int - Integer, long - Long, float - Float, double - Double, char - Character, boolean - Boolean.
(Note the full names Integer and Character.)A class is a composite (non-primitive) type: it groups data and methods, can be created by the user, and its variables refer to objects. Primitive types are built in, hold one value and have no methods. Wrapper classes bridge the two: Integer is a class whose objects hold one int.
Worked example
(2 marks) Name the wrapper classes of char and int, and the package in which they are found.
Try it first, then show the solutionSolution
- char → Character; int → Integer - 1 mark.
- Package java.lang, imported by default - 1 mark.
Answer: Character (for char) and Integer (for int); both are in java.lang, the default package.
- Parse methods: string to number
Parse methods convert a String containing a number into the primitive value:
int Integer.parseInt(String s): Integer.parseInt("45") → 45
long Long.parseLong(String s): Long.parseLong("9876543210") → 9876543210
float Float.parseFloat(String s): Float.parseFloat("2.5") → 2.5
double Double.parseDouble(String s): Double.parseDouble("25") → 25.0Why needed: input or data read as text cannot be used in arithmetic directly: "12" + "8" gives "128", but Integer.parseInt("12") + Integer.parseInt("8") gives 20.
If the string is not a valid number ("12a"), a runtime error occurs (NumberFormatException). Method names are case sensitive: parseDouble, not Parsedouble, and the argument must be a String: Double.parseDouble(25) is wrong.
Worked example
(1 mark) Which converts "25" to 25.0?
(a) Double.Parsedouble("25")
(b) Double.parse("25")
(c) Double.parseDouble("25")
(d) Double.parseDouble(25)Try it first, then show the solutionSolution
- Correct name and case, with a String argument.
Answer: (c) Double.parseDouble("25")
- Character test methods
These static methods of Character return boolean:
Character.isDigit(ch): true if ch is '0' to '9'. isDigit('7') → true.
Character.isLetter(ch): true for a letter. isLetter('g') → true; isLetter('5') → false.
Character.isLetterOrDigit(ch): true for a letter or a digit. isLetterOrDigit('#') → false.
Character.isLowerCase(ch): true for a lower-case letter. isLowerCase('a') → true.
Character.isUpperCase(ch): true for an upper-case letter. isUpperCase('a') → false.
Character.isWhitespace(ch): true for a space, tab or new line. isWhitespace(' ') → true.They are clearer than writing ranges like ch >= 'A' && ch <= 'Z', and the board may require them ('Use Character and String methods only').
Worked example
(1 mark) The method to check whether a character is a letter or a digit is:
(a) isDigit(char)
(b) isLetterOrDigit()
(c) isLetterOrDigit(char)
(d) isLETTERorDIGIT(char)Try it first, then show the solutionSolution
- Correct name and case, with a char argument.
Answer: (c) isLetterOrDigit(char)
- Character conversion methods
char Character.toUpperCase(ch): returns the upper-case form; non-letters are returned unchanged. toUpperCase('b') → 'B'; toUpperCase('B') → 'B'; toUpperCase('3') → '3'.
char Character.toLowerCase(ch): returns the lower-case form. toLowerCase('Q') → 'q'.These return a char; they do not change the original variable unless you assign: ch = Character.toUpperCase(ch);
Toggle case:
if (Character.isUpperCase(ch)) ch = Character.toLowerCase(ch);
else if (Character.isLowerCase(ch)) ch = Character.toUpperCase(ch);Worked example
(2 marks) Give the output:
char c = 'm';
System.out.println(Character.toUpperCase(c));
System.out.println(c);
System.out.println(Character.isUpperCase(Character.toUpperCase(c)));Try it first, then show the solutionSolution
- toUpperCase returns 'M' but c is not changed - 1 mark.
- isUpperCase('M') is true - 1 mark.
Answer: M
m
true- Autoboxing and unboxing
Autoboxing: the automatic conversion of a primitive value into an object of its wrapper class by the compiler.
Integer obj = 25; // int 25 boxed into an Integer object
Character c = 'x'; // char boxed into CharacterUnboxing: the automatic conversion of a wrapper object back into its primitive value.
int n = obj; // Integer unboxed to int
Double price = 4.5; // boxed
double d = price; // unboxed to 4.5Boxing = primitive → object; unboxing = object → primitive. Before autoboxing, programmers had to write these conversions by hand.
Worked example
(2 marks) Differentiate between boxing and unboxing with an example of each.
Try it first, then show the solutionSolution
- Boxing: primitive to wrapper object, e.g. Integer a = 10; - 1 mark.
- Unboxing: wrapper object to primitive, e.g. int b = a; - 1 mark.
Answer: Boxing converts a primitive value into an object of its wrapper class (Integer a = 10;), while unboxing converts the wrapper object back into a primitive value (int b = a;).
Library Classes in real life
Each concept, met in an everyday situation. Read the situation, answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.
parseInt
Suppose a form on a website collects your age as text, "15", and a program must check whether you are older than 13.
Why can't the program compare "15" > 13 directly, and how is it fixed?
Try it first, then show the solutionSolution
- "15" is a String; > works only on numbers.
- Integer.parseInt("15") converts it to the int 15.
- Then 15 > 13 is true.
Answer: Text must be converted first: int age = Integer.parseInt("15"); then age > 13 gives true.
Memory hook: Parse text before you do maths.
Character test methods
Imagine a password checker that requires at least one capital letter, one digit and no spaces.
Which Character methods does it need?
Try it first, then show the solutionSolution
- Capital letter: isUpperCase(ch).
- Digit: isDigit(ch).
- No spaces: isWhitespace(ch) must be false for every character.
Answer: Character.isUpperCase, Character.isDigit and Character.isWhitespace, applied to each character in a loop.
Memory hook: Test each character with the right is...() method.
Autoboxing
Suppose a teacher's program stores marks in a list that can hold only objects, but she types marks.add(87);.
How does Java accept a primitive here?
Try it first, then show the solutionSolution
- 87 is an int (primitive).
- The list needs Integer objects.
- Java automatically boxes 87 into an Integer.
Answer: By autoboxing: the int 87 is automatically wrapped into an Integer object.
Memory hook: Box it to store it; unbox it to use it.
Topics in this chapter
Library Classes: syntax and key facts
- Wrapper classes
- byte Byte, short Short, int Integer, long Long, float Float, double Double, char Character, boolean Boolean
- All in java.lang.
- Parse methods
- Integer.parseInt, Long.parseLong, Float.parseFloat, Double.parseDouble (String → number)
- Invalid text → NumberFormatException.
- Character methods
- isDigit, isLetter, isLetterOrDigit, isLowerCase, isUpperCase, isWhitespace (boolean); toLowerCase, toUpperCase (char)
- Static: Character.method(ch).
- Boxing
- 1.Autoboxing: primitive
- 2.object; Unboxing: object
- 3.primitive
How the board asks Library Classes
The question patterns to expect, and the method that works for each.
| Question type | How it is asked | Method |
|---|---|---|
| MCQ (Section A) | Correct method name (2024: isLetterOrDigit(char); 2025: parseDouble); package of Character (2025: java.lang). | Check exact spelling, case and argument type. |
| Short answer (2 marks) | Boxing vs unboxing (2024); fill in java.lang / java.util in a passage (2024); output of parse and Character methods. | Boxing → object; unboxing → primitive; wrappers in java.lang, Scanner in java.util. |
| Program (15 marks) | Count upper- and lower-case letters (Super string, 2025) and similar string programs. | Loop through charAt(i) and use Character methods; counters initialised before the loop. |
Tricks to remember Library Classes
Short memory aids. Say each one aloud once, then use it on a question the same day.
Two odd names
Only int and char change their names: Integer and Character; the rest just capitalise.
Use it when: Wrapper class names.
is...() asks, to...() changes
is-methods answer yes/no (boolean); to-methods return a converted char.
Use it when: Return types of Character methods.
Library Classes: board-level solved questions
Ordered from board level to HOTS. Cover the solution, write your own, then compare step by step.
Example 1: Package · 1 mark · MCQBoard level
Character class methods are found in:
(a) java.util
(b) java.lang
(c) java.awt
(d) java.io
Try it first, then show the solutionSolution
- Wrapper classes are in the default package java.lang.
Answer: (b) java.lang
Example 2: Assertion and reason: parse · 1 mark · Assertion-reasonHarder board level
Assertion (A): Integer.parseInt("12") + Integer.parseInt("8") gives 20.
Reason (R): The parse methods convert numeric strings into primitive numbers.
(a) Both A and R are true and R is the correct explanation of A
(b) Both A and R are true but R is not the correct explanation of A
(c) A is true but R is false
(d) A is false but R is true
Try it first, then show the solutionSolution
- Both strings become ints 12 and 8; their sum is 20.
Answer: (a) Both A and R are true and R is the correct explanation of A
Example 3: Mixed output · 2 marks · Short answerHOTS / competency
Give the output:
String a = "45.50", b = "54.50";
double d = Double.parseDouble(a) + Double.parseDouble(b);
System.out.println(d);
System.out.println((int) d + a);
Try it first, then show the solutionSolution
- 45.5 + 54.5 = 100.0.
- (int) d = 100; 100 + "45.50" joins as text: 10045.50.
Answer: 100.0
10045.50
Example 4: Character outputs · 2 marks · Very short answerHarder board level
Give the output: System.out.println(Character.isLetterOrDigit('#') + " " + Character.isWhitespace('\t') + " " + Character.toLowerCase('Z'));
Try it first, then show the solutionSolution
- '#' is neither letter nor digit: false. A tab is whitespace: true.
- toLowerCase('Z') is 'z'.
Answer: false true z
Example 5: Boxing and unboxing · 2 marks · Very short answerBoard level
Identify boxing and unboxing:
Integer x = 40;
int y = x + 5;
Double z = 2.5;
double w = z;
Try it first, then show the solutionSolution
- Integer x = 40; and Double z = 2.5; box primitives into objects.
- x + 5 and double w = z; unbox objects to primitives.
Answer: Autoboxing: Integer x = 40; and Double z = 2.5;. Unboxing: x in int y = x + 5; (y = 45) and double w = z;.
Example 6: Character counts (Section B) · 15 marks · Long answerHarder board level
Write a program to accept a sentence and count its letters, digits, whitespace characters and other characters, and print 'Balanced' if the numbers of upper-case and lower-case letters are equal. Use Character methods.
Try it first, then show the solutionSolution
- import java.util.Scanner;
class CharCount
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Sentence: ");
String s = sc.nextLine();
int let = 0, dig = 0, sp = 0, oth = 0, up = 0, low = 0; - for (int i = 0; i < s.length(); i++)
{
char ch = s.charAt(i);
if (Character.isLetter(ch))
{
let++;
if (Character.isUpperCase(ch)) up++;
else if (Character.isLowerCase(ch)) low++;
}
else if (Character.isDigit(ch)) dig++;
else if (Character.isWhitespace(ch)) sp++;
else oth++;
} - System.out.println("Letters: " + let + " Digits: " + dig + " Spaces: " + sp + " Others: " + oth);
if (up == low)
System.out.println("Balanced");
else
System.out.println("Not balanced");
}
} - Counters are initialised before the loop; == (not =) compares the counts.
- Trace "ICSE 2027 exam!": letters I, C, S, E, e, x, a, m = 8 (4 upper, 4 lower); digits 2, 0, 2, 7 = 4; 2 spaces; '!' = 1 other.
Answer: Sample run:
Sentence: ICSE 2027 exam!
Letters: 8 Digits: 4 Spaces: 2 Others: 1
Balanced
Example 7: Toggle case · 15 marks · Long answerHOTS / competency
Write a program to accept a word and print it with the case of every letter changed (upper to lower and lower to upper), leaving other characters unchanged.
Try it first, then show the solutionSolution
- import java.util.Scanner;
class Toggle
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Word: ");
String w = sc.next();
String res = ""; - for (int i = 0; i < w.length(); i++)
{
char ch = w.charAt(i);
if (Character.isUpperCase(ch))
ch = Character.toLowerCase(ch);
else if (Character.isLowerCase(ch))
ch = Character.toUpperCase(ch);
res = res + ch;
} - System.out.println(res);
}
} - else if is needed: with two separate ifs, an upper-case letter would be turned lower and then back to upper.
- Trace "JaVa17": J→j, a→A, V→v, a→A, 1, 7 unchanged → "jAvA17".
Answer: Sample run:
Word: JaVa17
jAvA17
Case-study practice (Section B style)
Read the situation, then answer every part. In the board paper this is a 10-mark question split into 2 + 3 + 5 marks.
Marks entered as text
Imagine a school portal stores marks as strings: String m1 = "78", m2 = "86.5". A student writes System.out.println(m1 + m2); expecting the total, and later Integer.parseInt(m2).
(i) · 2 marks
What does m1 + m2 print, and why?
Answer
Answer: 7886.5, because + with Strings joins (concatenates) them instead of adding.
Output 1 mark; reason 1 mark.
(ii) · 3 marks
Why does Integer.parseInt(m2) fail? Which method should be used?
Answer
Answer: "86.5" is not a valid integer string, so parseInt throws a NumberFormatException at run time. Use Double.parseDouble(m2), which gives 86.5.
Reason 2 marks; method 1 mark.
(iii) · 5 marks
Write statements to print the correct total and explain the role of wrapper classes here.
Answer
Answer: double total = Integer.parseInt(m1) + Double.parseDouble(m2); System.out.println(total); → 164.5. Wrapper classes (Integer, Double) provide static parse methods that convert numeric text to primitive values so that arithmetic is possible.
Statements 3 marks; explanation 2 marks.
Where the marks are
How a typical answer is split into step marks. Show every step: a right final answer alone rarely earns full marks.
Differentiate between boxing and unboxing. (2 marks) (2 marks)
| Step | Marks |
|---|---|
| Boxing: primitive to wrapper object with example. | 1 |
| Unboxing: wrapper object to primitive with example. | 1 |
String program using Character methods (letter/digit/space counts). (15 marks) (15 marks)
| Step | Marks |
|---|---|
| Input with nextLine(); counters initialised before loop. | 3 |
| Loop over length() with charAt(i). | 3 |
| Correct Character methods for each category. | 4 |
| Upper/lower counts and == comparison. | 2 |
| Output messages as required. | 3 |
Where students lose marks in Library Classes
The slips examiners see most often, and what to write instead.
Mistake: Using ranges instead of Character methods
The 2025 examiners reported ch >= 'A' && ch <= 'Z' in the Super string program that required Character methods.
Do this: Use Character.isUpperCase / isLowerCase when the question says so.
Usually costs: 2 to 4 marks of 15.
Mistake: Interchanging boxing and unboxing
Reported by the 2024 examiners.
Do this: Boxing puts a primitive in a box (object); unboxing takes it out.
Usually costs: 2 marks.
Mistake: Wrong package
In 2025 many chose java.util for Character; in 2024 some wrote 'wrapper classes' for java.lang.
Do this: Wrappers: java.lang; Scanner: java.util.
Usually costs: 1 mark.
Mistake: Wrong method syntax
The 2025 MCQ offered Parsedouble, parse and a non-String argument.
Do this: Double.parseDouble("25"): exact case, String argument.
Usually costs: 1 mark.
Mistake: Counters initialised inside the loop; = instead of ==
Both errors were reported in the 2025 Super string program.
Do this: Initialise counters once before the loop; compare with ==.
Usually costs: 2 to 3 marks.
Practice questions on Library Classes
Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.
Q1 · 1 mark · MCQBoard level
The wrapper class of char is:
(a) Char
(b) Character
(c) Chr
(d) StringHint
Full name.
Answer
(b) Character
Q2 · 1 mark · MCQBoard level
Character.isUpperCase('a') returns:
(a) A
(b) true
(c) false
(d) aHint
boolean.
Answer
(c) false
Q3 · 1 mark · MCQHarder board level
Integer p = 7; has already been declared. Which statement causes unboxing?
(a) Integer a = 5;
(b) int b = p;
(c) Double c = 2.0;
(d) Character d = 'k';Hint
Object to primitive.
Answer
(b) int b = p;
Q4 · 2 marks · Very short answerBoard level
State the return type and purpose of Character.isWhitespace(char).
Hint
Spaces.
Answer
It returns boolean: true if the character is a white-space character such as a space, tab or new line, otherwise false.
Q5 · 2 marks · Short answerHOTS / competency
Give the output: System.out.println(Integer.parseInt("7") * 2 + "7" + 2);
Hint
Left to right.
Answer
1472 (7 × 2 = 14; then "14" + "7" + "2")
Q6 · 2 marks · Very short answerBoard level
Fill in the blanks: Wrapper classes are part of the ______ package; the Scanner class is part of the ______ package and must be imported.
Hint
lang, util.
Answer
java.lang; java.util
Q7 · 15 marks · Long answerHarder board level
Write a program to accept a String of digits (e.g. "40213") and print the sum of its digits using Character.isDigit and type conversion.
Hint
ch - '0'.
Answer
import java.util.Scanner;
class DigitString
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter digits: ");
String s = sc.next();
int sum = 0;
for (int i = 0; i < s.length(); i++)
{
char ch = s.charAt(i);
if (Character.isDigit(ch))
sum = sum + (ch - '0');
}
System.out.println("Sum = " + sum);
}
}
Trace "40213": 4 + 0 + 2 + 1 + 3 = 10 → Sum = 10.Q8 · 2 marks · Short answerHOTS / competency
Why is it better to use Character.isUpperCase(ch) than ch >= 'A' && ch <= 'Z'?
Hint
Clarity; question demand.
Answer
It is clearer and less error-prone, it also works for upper-case letters beyond A to Z in Unicode, and when a question says 'use Character methods' the examiners expect the library method (the 2025 examiners listed range comparisons as an error).
Q9 · 2 marks · Very short answerHarder board level
What happens when Integer.parseInt("12a") runs?
Hint
Runtime.
Answer
A runtime error (NumberFormatException) occurs, because "12a" is not a valid integer string.
Test your recall
Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.
1.Wrapper class of int?Show answer
Integer
2.Character.toUpperCase('5')?Show answer
'5' (unchanged)
3.Return type of isDigit?Show answer
boolean
4.Primitive to object automatically?Show answer
Autoboxing
5.Package of wrapper classes?Show answer
java.lang
Best order to study it
- Wrapper classes and their names.
- Parse methods with examples.
- Character test methods.
- toUpperCase and toLowerCase.
- Autoboxing and unboxing.
- Practise one string program with Character methods.
Quick revision checklist
The night before the exam: can you do each of these without looking?
- Wrappers in java.lang: Integer, Character, Double...
- parseInt, parseLong, parseFloat, parseDouble: String → number.
- isDigit, isLetter, isLetterOrDigit, isLowerCase, isUpperCase, isWhitespace → boolean.
- toLowerCase, toUpperCase → char; assign to keep the change.
- Autoboxing: primitive → object; unboxing: object → primitive.
Library Classes: frequently asked questions
Do I need Integer.toString or valueOf from wrapper classes?
They are not in the wrapper list; String.valueOf() is covered under String handling.
Does Character.toUpperCase change the variable?
No. It returns a new char; write ch = Character.toUpperCase(ch); to change ch.
Do I need to import anything for Character methods?
No. Character is in java.lang, which is always available.
Based on: CISCE ICSE 2027 Computer Applications syllabus; CISCE Analysis of Pupil Performance ICSE 2025: Computer Applications (with the 2025 board paper)