Library Classes
Library Classes
The asterisk(*) sign indicates that all the classes in the imported package can be used in the
program.
Question 3
Wrapper classes wrap the value of a primitive type in an object. Wrapper classes are present in
java.lang package. The different wrapper classes provided by Java are Boolean, Byte, Integer,
Float, Character, Short, Long and Double.
Question 4
Differentiate between:
(a) isUpperCase() and toUpperCase()
isUpperCase() toUpperCase()
It is used to check if the character given as its argument It is used to convert the character given as its
is in upper case or not. argument to upper case
parseInt() toString()
Primitive Data Types are built-in data types defined by Composite Data Types are defined by the
Java language specification programmer
Examples of Primitive Data Types are byte, short, int, long, Examples of Composite Data Types are Class
float, double, char, boolean and Array
Question 5(i)
Question 5(ii)
java.lang
Question 5(iii)
Write the prototype of a function check which takes an integer as an argument and returns a
character.
char check(int n)
Question 2
Double.toString()
It is used to convert double data to a string.
Question 3
Integer.valueOf()
Question 4
Character.isDigit()
Question 5
Character.isWhitespace()
Question 1
char ch = '*';
boolean b = Character.isLetter(ch);
System.out.println(b);
Output
false
Question 2
char c = 'A';
int n = (int) c + 32;
System.out.println((char)n);
Output
Question 3
String s= "7";
int t =Integer.parseInt(s);
t=t+1000;
System.out.println(t);
Output
1007
Question 4
char c = 'B';
int i = 4;
System.out.println(c+i);
System.out.println((int)c+i);
Output
70
70
Question 5
char ch = 'y';
char chr = Character.toUpperCase(ch);
int p = (int) chr;
System.out.println(chr + "\t" + p);
Output
Y 89
Question 6
int n = 97;
char ch = Character.toUpperCase((char)n);
System.out.println(ch + " Great Victory");
Output
A Great Victory
Question 7
char ch = 'x'; int n = 5;
n = n + (int)ch;
char c = (char)n;
System.out.println((char)((int)c-26));
Output
c
Question 8
char ch = 'A';
char chr = Character.toLowerCase(ch);
int n = (int)chr-32;
System.out.println((char)n + "\t" + chr);
Output
A a