This section of our 1000+ Java MCQs focuses on java.lang library of Java Programming Language.
1. Which of these classes is not included in java.lang?
a) Byte
b) Integer
c) Array
d) Class
View Answer
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
View Answer
Explanation: None.
3. Which of these is a super class of wrappers Double & Integer?
a) Long
b) Digits
c) Float
d) Number
View Answer
Explanation: Number is an abstract class containing subclasses Double, Float, Byte, Short, Integer and Long.
4. Which of these is a wrapper for simple data type float?
a) float
b) double
c) Float
d) Double
View Answer
Explanation: None.
5. Which of the following is a method of wrapper Float for converting the value of an object into byte?
a) bytevalue()
b) byte byteValue()
c) Bytevalue()
d) Byte Bytevalue()
View Answer
Explanation: None.
6. Which of these methods is used to check for infinitely large and small values?
a) isInfinite()
b) isNaN()
c) Isinfinite()
d) IsNaN()
View Answer
Explanation: isinfinite() method returns true is the value being tested is infinitely large or small in magnitude.
7. Which of the following package stores all the simple data types in java?
a) lang
b) java
c) util
d) java.packages
View Answer
Explanation: None.
8. What will be the output of the following Java code?
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
View Answer
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.
Output:
$ javac isinfinite_output.java $ java isinfinite_output true
9. What will be the output of the following Java code?
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
View Answer
Explanation: 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
10. What will be the output of the following Java code?
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
View Answer
Explanation: None.
output:
$ javac binary.java $ java binary 10001
Sanfoundry Global Education & Learning Series – Java Programming Language.
- Practice Programming MCQs
- Apply for Java Internship
- Check Programming Books
- Apply for Computer Science Internship
- Practice BCA MCQs