java.lang Package Interview Questions And Answers

Java Programming : java.lang Package

Here are the java.lang package interview questions and answers with the PDFs to download. All questions are in form of MCQ

1. Which of the following class is not included in java.lang?

[A] Byte
[B] Integer
[C] Array
[D] Class

Answer: C. Array

Explanation:

Array class is a member of java.util.
2. Which of these is a process of converting a simple data type into a class?

[A] type wrapping
[B] type conversion
[C] type casting
[D] None of the Mentioned.

Answer: A. type wrapping

Explanation:

Using Wrapper class we convert the Simple data type into a class.
3. Which of these is a super class of wrappers Double & Integer?
[A] Long
[B] Digits
[C] Float
[D] Number

Answer: D. Number

Explanation:

Number is an abstract class containing subclasses Double, Float, Byte, Short, Integer and Long.
4. Which of these is wrapper for simple data type float?
[A] float
[B] double
[C] Float
[D] Double

Answer: C. Float

Explanation:

None
5. Which of these methods is used to check for infinitely large and small values?
[A] isInfinite()
[B] isNaN()
[C] Isinfinite()
[D] IsNaN()

Answer: A. isInfinite()

Explanation:

isinfinite() method returns true is the value being tested is infinitely large or small in magnitude.
6. What is the output of this program?


class isinfinite_output {
public static void main(String args[]) {
Double d = new Double(1 / 0.);
boolean x = d.isInfinite();
System.out.print(x);
}
}

[A] 0
[B] 1
[C] true
[D] False

Answer: C. true

Explanation:

isInfinite() method returns true is the value being tested is infinitely large or small in magnitude. 1/0. is infinitely large in magnitude hence true is stored in x.
7. What is the output of this program?


class isNaN_output {
public static void main(String args[]) {
Double d = new Double(1 / 0.);
boolean x = d.isNaN();
System.out.print(x);
}
}

[A] 0
[B] 1
[C] True
[D] False

Answer: D. False

Explanation:

isisNaN() method returns true is the value being tested is a number. 1/0. is infinitely large in magnitude, which cant not be defined as a number hence false is stored in x.
8. What is the output of this program?


class binary {
public static void main(String args[]) {
int num = 17;
System.out.print(Integer.toBinaryString(num));
}
}
[A] 1001
[B] 10011
[C] 11011
[D] 10001

Answer: D. 10001

Explanation:

None
9. Which of these operators can be used to concatenate two or more String objects?
[A] +
[B] +=
[C] &
[D] ||

Answer: A. +

Explanation:

operator + is used to concatenate strings, Example String s = “i ” + “like ” + “java”; String s contains “I like java”.
10. Which of these method of class String is used to obtain length of String object?
[A] get()
[B] Sizeof()
[C] lengthof()
[D] length()

Answer: D. length()

Explanation:

Method length() of string class is used to get the length of the object which invoked method length().

Are these questions helpful for you?


Comments: (Your feedback is valuable to us)

chotu 1 year ago Reply

NICE


Narasimha Rao Kandula 2 years ago Reply

Good


Srishti Bisht 2 years ago Reply

download