100% found this document useful (1 vote)
336 views5 pages

Class 10 Java Library Classes Q&A

The document contains important questions for Class 10 related to library classes and data types in Java, including multiple-choice questions and short answer questions. Topics covered include memory allocation for class objects, wrapper classes, primitive and composite data types, and various methods for data conversion. Additionally, it includes assignment questions that explore the definitions and uses of library classes, primitive types, and concepts like autoboxing and auto-unboxing.

Uploaded by

asitakumar25
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
336 views5 pages

Class 10 Java Library Classes Q&A

The document contains important questions for Class 10 related to library classes and data types in Java, including multiple-choice questions and short answer questions. Topics covered include memory allocation for class objects, wrapper classes, primitive and composite data types, and various methods for data conversion. Additionally, it includes assignment questions that explore the definitions and uses of library classes, primitive types, and concepts like autoboxing and auto-unboxing.

Uploaded by

asitakumar25
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Class 10 Library classes Important Questions

Q1. Memory is allocated for class objects when

Options

(a) Class is defined


(b) Function is called
(c) Both (a) and (b)
(d) Object is created

Q2. The process of converting wrapper class object to primitive data


type is called :

Options

(a) Boxing
(b) Unboxing
(c) Conversion
(d) Post Boxing

Q3. Name a method to convert a value to string ? Give an example.

4) Which of the following is a primitive data type?


1. int
2. float
3. char
4. All of these
5) Which of the following is a composite data type?
1. int
2. float
3. char
4. String
6) The return type of the isLowerCase() method is ............... .
1. int
2. boolean
3. char
4. String
7) The return type of the toLowerCase() method is ............... .
1. int
2. boolean
3. char
4. String
8) The value returned by [Link]("-321") is ............... .
1. -321
2. 321
3. 321.0
4. "321"
9) Name the method that can convert a string into its integer equivalent.
1. [Link]()
2. [Link]()
3. [Link]()
4. [Link]()
10) What will be the result when the following statement is executed?
int count = new Integer(12);
1. Variable count will be initialised with value 12.
2. Variable count will be initialised with default value of int, i.e., zero
(0).
3. An array count will be initialised with 12 elements, all having a
default value of zero (0).
4. Value of count will be unknown as no value has been assigned
yet.
11) In which package is the wrapper class Integer available?
1. [Link]
2. [Link]
3. [Link]
4. [Link]

12) state the data and value of y after the following is executed:
Char X = ‘7’;
Y = [Link](x);

. 13) Write the output of the following program code:


Char ch;
int x = 97;
do
{
Ch = (char) x;
[Link] (ch + “ “);
if(x% 10== 0)
Break;
++x;
}
while (x <= 100);

14) what will be the output when the following code segments are
executed?
(i) String s = “1001”;
int x=[Link](s);
Double y = [Link](s);
[Link](“x=”+x);
[Link](“y=”+y);
(ii) [Link](“The King said\”Begin at the beginning!\”to me”);
15) Name any two wrapper classes.
16) Name the wrapper classes of char type and boolean type.
17) State the package that contains the class:
(i) BufferedReader (ii) scanner

18) What is the data type that the following library functions return?
(i) isWhiteSpace(char ch)
(ii) [Link]( )

19) State the value of n and ch.


Char c=’A’;
int n=c+1;
char ch=(char)n;

20) 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.

21) what are library classes? Give an example.

22) Write a function to check whether a character is a blank or not.


Assignment Questions
Question 1
What are the library classes in Java? What is their use?
Question 2
Define Primitive data type
Question 3
Define Composite data type
Question 4
Define User-defined data type
Question 5
Why is a class called a composite data type? Explain.
Question 6
What is a wrapper class? Name three wrapper classes in Java.
Question 7
Explain the terms, Autoboxing and Auto-unboxing in Java.
Question 8
How do you convert a numeric string into a double value?
Question 9
How can you check if a given character is a digit, a letter or a space?
Question 10
Distinguish between isLowerCase() and toLowerCase()
Question 11
Distinguish between isUpperCase() and toUpperCase()
Distinguish between isDigit() and isLetter()
Distinguish between parseFloat() and parseDouble()

Common questions

Powered by AI

The method Character.isLetter(char) checks if the specified character is a letter and returns a boolean value: true if the character is a letter according to Unicode standards, otherwise false. It's useful for input validation and parsing tasks in text processing applications .

The isLowerCase() method returns a boolean and checks if a specified character is in lowercase, helping in conditional checks. On the other hand, toLowerCase() returns a new string where all the uppercase characters have been converted to lowercase, aiding in string manipulation. They cater to different use cases: one for case validation and the other for modifying the case of strings .

In Java, memory is allocated for class objects when an object is created. This means that until an object is instantiated using 'new', memory for the object isn't allocated .

The Java code 'int count = new Integer(12);' will initialize the variable 'count' with the value 12. In this statement, the 'new Integer(12)' creates an Integer object, which is immediately unboxed to an 'int' type due to assignment to an 'int' variable .

Autoboxing in Java is the automatic conversion that the Java compiler makes between the primitive data types and their corresponding object wrapper classes, such as converting an 'int' to an 'Integer'. The primary advantage of autoboxing is that it eliminates the need for manual conversion, leading to more readable and maintainable code. Autoboxing is used particularly in data structures such as lists or maps that work with objects instead of primitive types .

A class is termed a composite data type because it encapsulates multiple data types and methods, allowing complex data structures to exist as a single entity. Unlike primitive data types which hold a single value, classes can contain both primitive and non-primitive data, thus providing extensive data manipulation capabilities through encapsulation, inheritance, and polymorphism .

The Integer wrapper class is included in the java.lang package. This package is significant because it provides classes that are fundamental to the design of the Java programming language. It is automatically imported by default in all Java programs, making essential classes like Integer easily accessible without the need for manual imports .

To convert a numeric string into a double value in Java, use the Double.parseDouble() method. This method takes a string as an input and returns its equivalent double value. For example, Double.parseDouble("3.14") would return the double value 3.14 .

The process of converting a wrapper class object back to a primitive data type in Java is called Unboxing .

You would use the Integer.parseInt() method when you need to convert a string that represents an integer value into an actual integer primitive type. A common use case is processing user input from a GUI or file where numbers are read as strings. For instance, if a string '"123"' is read, applying Integer.parseInt("123") will convert it into an integer value 123 .

You might also like