Professional Documents
Culture Documents
CLASS X
LIBRARY CLASSES
Answer the following questions
Q1What is package?
Ans: A package is a collection of classes containing built-in functions.
Q2 what is wrapper class
Ans: Wrapper class is a library class that is used to convert primitive data type into non-
primitive data type and vica-versa. It also convert any primitive data type to a primitive
object. The different wrapper classes provided by Java are Boolean, Byte, Integer, Float, Character,
Short, Long and Double.
Ans: The asterisk(*) sign indicates that all the classes in the imported package can be used in the
program.
Q4Differentiate between:
isUpperCase() toUpperCase()
It is used to check if the character given It is used to convert the character given
as its argument is in upper case or not. as its argument to upper case
parseInt() toString()
Primitive Data Types are Java's fundamental Composite Data Types are created by
data types using Primitive Data Types
Primitive Data Types are built-in data types Composite Data Types are defined by
defined by Java language specification the programmer
Examples of Primitive Data Types are byte, Examples of Composite Data Types are
short, int, long, float, double, char, boolean Class and Array
Ans java.lang
Q1 Float.parseFloat()
It is used to convert string data into float data.
Q2 Double.toString()
It is used to convert double data to a string.
Q3 Integer.valueOf()
It is used to convert string data into the Integer wrapper object.
Q4 Character.isDigit()
It is used to check if the character given as its argument is a digit.
Q5 Character.isWhitespace()
It is used to check if the character given as its argument is a whitespace.
Q.7 state the data and value of y after the following is executed:
Char X = ‘7’;
Y = Character.isLetter(x);
Ans. It is a boolean type data and the value of y is false.
Q.8 Write the output of the following program code:
Char ch;
int x = 97;
do
{
Ch = (char) x;
System.out.println (ch + “ “);
if(x% 10== 0)
Break;
++x;
}
while (x <= 100);
Ans. a
b
c
d
Q.9 what will be the output when the following code segments are executed?
(i) String s = “1001”;
int x=Integer.valueOf(s);
Double y = Double.valueOf(s);
System.out.println(“x=”+x);
System.out.println(“y=”+y);
(ii) system.out.println(“The King said\”Begin at the beginning!\”to me”);
Ans. (i) x=1001
Y=1001.0
(ii) The king said “Begin at the beginning!” to me
Q.10 Name any two wrapper classes.
Ans. (i) Character wrapper class
(ii) Integer wrapper class
Q.11. Name the wrapper classes of char type and boolean type.
Ans. The wrapper class of char type is character and boolean type is Boolean.
Q.12 State the package that contains the class:
(i) BufferedReader (ii) scanner
Ans. (i) java.jo.* (ii) java.until.*
Q.13 What is the data type that the following library functions return?
(i) isWhiteSpace(char ch) (ii) Math.random( )
Ans. (i) Boolean type (ii)double type
Q.14 State the value of n and ch.
Char c=’A’;
int n=c+1;
char ch=(char)n;
Ans. The value of n = 66 and ch = B
Q.15 state the method that:
(i) converts a string to a primitive float data type.
(ii)determines if the specified character is an upper case character.
Ans. (i) Float.parseFloat(String)
(ii) Character.isUpperCase(character)
Q.16 what are library classes? Give an example.
Ans. The JCL (Java Class Library) includes various packages with in-built functions to provide
effective support to the users for developing productive logic,
e.g., java.io.*;
Q.17 Write a function to check whether a character is a blank or not.
Ans. Character.iswhiteSpace(ch);