Library Classes
ICSE Class 10 · Computer Applications · Chapter 5
What this chapter covers
- Library classes and the java.lang package
- Class as a composite type
- Wrapper classes
- Autoboxing and unboxing
- Conversion methods: from String to number
- Character class methods: testing a character
- Character class methods: changing case
- Using library classes together
Key points
- A library class is a ready-made class supplied with Java; the java.lang package is imported automatically.
- Java has eight primitive types; classes, arrays and interfaces are composite (reference) types.
- A class is a user-defined data type: its objects hold data members and methods together.
- A primitive variable stores its value; a composite variable stores a reference, with default value `null`.
- Every primitive type has a wrapper class: `Byte`, `Short`, `Integer`, `Long`, `Float`, `Double`, `Character`, `Boolean`.
- Autoboxing converts a primitive to its wrapper object automatically; unboxing converts it back.
- Unboxing a `null` wrapper causes a `NullPointerException`.
- `parseInt`, `parseLong`, `parseFloat` and `parseDouble` convert a `String` into a number; an invalid string causes a `NumberFormatException`.
- `isDigit`, `isLetter`, `isLetterOrDigit`, `isLowerCase`, `isUpperCase` and `isWhitespace` take a `char` and return a `boolean`.
- `toUpperCase` and `toLowerCase` return a `char`; non-letters come back unchanged, and the original variable is not modified.
- All these methods are `static`, so they are called with the class name, such as `Character.isDigit(ch)`.
Questions answered
What is a wrapper class? Name the wrapper classes of `char` and `int`.
Define autoboxing and unboxing, with one example of each.
State two differences between a primitive data type and a composite data type.
Why is a class called a user-defined data type?
Which package contains the wrapper classes? Why do programs not import it?
Give the output: `System.out.println(Integer.parseInt("25") + Integer.parseInt("75"));`
Give the output: `System.out.println("25" + "75");` and explain the difference from question 6.
What happens when `Integer.parseInt("15.5")` is executed? Which method should be used instead?
Past board exam questions
ICSE 2026 board paper · 1 mark
The output of the statement: System.out.println(Character.toUpperCase('b') + 2); is:
- 66
- 100
- 68
- 98
Show answer
ICSE 2026 board paper · 1 mark
What is the type of parameter to be given for the method parseInt( )?
- double
- String
- char
- int
Show answer
ICSE 2025 board paper · 1 mark
Character class methods are found in the package called:
- java.util
- java.lang
- java.awt
- java.io
Show answer
ICSE 2025 compartment paper · 1 mark
What will be the output of the following Java method? Character.isLetterOrDigit('\n')
- 1
- 0
- true
- false
Show answer
ICSE 2025 compartment paper · 1 mark
Identify the static method from the list given below:
- length( )
- nextLine( )
- substring(int)
- isLetter(char)
Show answer
ICSE 2025 sample paper · 1 mark
The method to convert a lowercase character to uppercase is:
- String.toUpperCase( )
- Character.isUppercase ( char )
- Character.toUpperCase( char )
- toUpperCase ( )
Show answer
ICSE 2025 board paper · 1 mark
Which of the following converts “25” to 25.0?
- Double.Parsedouble(“25”)
- Double.parse(“25”)
- Double.parseDouble(“25”)
- Double.parseDouble(25)
Show answer
ICSE 2025 sample paper · 1 mark
Assertion (A): Integer class can be used in the program without calling a package. Reason (R): It belongs to the default package java.lang.
- Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A)
- Both Assertion (A) and Reason (R) are true and Reason (R) is not a correct explanation of Assertion(A)
- Assertion (A) is true and Reason (R) is false
- Assertion (A) is false and Reason (R) is true