Java MCQs on java.lang library of Java Programming Language.
1. Which of these classes is not included in java.lang? Answer: c 2. Which of these is a process of converting a simple data type into a class? Answer: a 3. Which of these is a super class of wrappers Double & Integer? Answer: d 4. Which of these is a wrapper for simple data type float? Answer: c 5. Which of the following is a method of wrapper Float for converting the value of an object into byte? Answer: b 6. Which of these methods is used to check for infinitely large and small values? Answer: a 7. Which of the following package stores all the simple data types in java? Answer: a 8. What will be the output of the following Java code? a) 0 9. What will be the output of the following Java code? a) 0 10. What will be the output of the following Java code? a) 1001
a) Byte
b) Integer
c) Array
d) Class
Clarification: Array class is a member of java.util.
a) type wrapping
b) type conversion
c) type casting
d) none of the Mentioned
Clarification: None.
a) Long
b) Digits
c) Float
d) Number
Clarification: Number is an abstract class containing subclasses Double, Float, Byte, Short, Integer and Long.
a) float
b) double
c) Float
d) Double
Clarification: None.
a) bytevalue()
b) byte byteValue()
c) Bytevalue()
d) Byte Bytevalue()
Clarification: None.
a) isInfinite()
b) isNaN()
c) Isinfinite()
d) IsNaN()
Clarification: isinfinite() method returns true is the value being tested is infinitely large or small in magnitude.
a) lang
b) java
c) util
d) java.packages
Clarification: None.
class isinfinite_output
{
public static void main(String args[])
{
Double d = new Double(1 / 0.);
boolean x = d.isInfinite();
System.out.print(x);
}
}
b) 1
c) true
d) false
Clarification: 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.
Output:
$ javac isinfinite_output.java
$ java isinfinite_output
true
class isNaN_output
{
public static void main(String args[])
{
Double d = new Double(1 / 0.);
boolean x = d.isNaN();
System.out.print(x);
}
}
b) 1
c) true
d) false
Clarification: isisNaN() method returns true is the value being tested is a number. 1/0. is infinitely large in magnitude, which cannot be defined as a number hence false is stored in x.
Output:
$ javac isNaN_output.java
$ java isNaN_output
false
class binary
{
public static void main(String args[])
{
int num = 17;
System.out.print(Integer.toBinaryString(num));
}
}
b) 10011
c) 11011
d) 10001
Clarification: None.
output:
$ javac binary.java
$ java binary
10001