Std X
Computer Applications
Library Classes
The inbuilt classes in Java are known as Library Classes and these
contain the user defined methods to perform the specific task.
Sub-topics to be covered
1. Recapitulation
2. Wrapper classes
3. Methods of Wrapper class
4. Autoboxing and Unboxing
Recapitulation
a. What is a package? Name some inbuilt
packages.
b. How to access the classes of the package?
c. Why is a class known as user defined data
type?
d. Differentiate between primitive data type and
composite data types.
Library Classes
java.lang java.io java.util
Math String Wrapper Scanner
Library Classes Purpose
Java.io Contains input/output functions.
Java.lang Contains functions for character,
mathematical and string operations.
Java.util Contains functions to develop utility
programs.
Wrapper Classes
It provides the facility to contain primitive data
values in terms of objects.
Wrapper class Data type
Character char
Byte byte
Short short
Integer int
Long long
Float float
Double Double
Boolean boolean
Methods of Character Wrapper Classes
1. boolean isDigit(char ch),
2. boolean isLetter(char ch),
3. boolean isLetterOrDigit(char ch),
4. boolean isLowerCase(char ch),
5. boolean isUpperCase(char ch),
6. boolean isWhitespace(char ch),
7. char toLowerCase (char ch)
8. char toUpperCase(char ch)
Function name Description Return Example
type
Character.isLetter(ch) Checks whether boolean Character.isLetter(‘a’)
a character is a returns true.
letter or not.
Character.isDigit(ch) Checks whether boolean Character. isDigit(‘a’)
a character is a returns false.
digit or not.
Character.isLetterOrDigit(ch) Checks whether boolean Character.isLetterOrDi
a character is git(‘a’) returns true.
either a letter or
a digit or not.
Character.isWhitespace(ch) Checks whether boolean Character.isWhiteSpace
a character is a (‘ ’) returns true.
blank space not.
Function name Description Return Example
type
Character.isUpperCase(ch) Checks whether boolean Character.isUpperCase
a character is a (‘a’) returns false.
uppercase letter
or not.
Character.isLowerCase(ch) Checks whether boolean Character.isLowerCase(‘a’
a character is a ) returns true.
lowercase letter
or not.
Character.toLowerCase(ch) Converts a given char Character.toLowerCase(‘a
character to ’) returns ‘a’.
lowerase.
Character.toUpperCase(ch) Converts a given char Character.toUpperCase(‘
character to a’) returns ‘A’.
uppercase.
Methods of Wrapper Classes to convert
String to Numeric form
1. int Integer.parseInt(String s),
2. long Long.parseLong(String s),
3. float Float.parseFloat(String s),
4. double Double.parseDouble(String s),
Methods of Wrapper Classes to convert
Numeric form to String
1. String Integer.toString(int a),
2. String Double.toString(double a)
3. String Long.toString(long a)
4. String Float.toString(float a)
Autoboxing and Unboxing
1. Autoboxing : is the process by which primitive
data type is automatically encapsulated
(boxed) into its equivalent type wrapper
whenever an object that type is needed. There is
no need explicitly construct an object.
Integer ob = new Integer(45);
2. Unboxing : is the process by which value of a
boxed object is automatically extracted
(unboxed)from the type wrapper when its value
is needed .
int a = ob;
QUESTIONS
1.State the data type and value of res after the
following is executed:
char ch='t';
res= Character.toUpperCase(ch);
2. Write the return type of the following
library function:
(i) isLetterOrDigit(char)