457). Which of these is a super class of wrappers Double and Float?
[A]Long
[B]Digits
[C]Float
[D]Number
Show Answer
Correct Answer: Number
Notes:
Answer: d
Explanation: Number is an abstract class containing subclasses Double, Float, Byte, Short, Integer and Long.
458). Which of the following methods return the value as a double?
[A]doubleValue()
[B]converDouble()
[C]getDouble()
[D]getDoubleValue()
Show Answer
Correct Answer: doubleValue()
Notes:
Answer: a
Explanation: None.
459). Which of these methods can be used to check whether the given value is a number or not?
[A]isNaN()
[B]isNumber()
[C]checkNaN()
[D]checkNumber()
Show Answer
Correct Answer: isNaN()
Notes:
Answer: a
Explanation: isNaN() methods returns true if num specified is not a number, otherwise it returns false.
460). Which of these method of Double wrapper can be used to check whether a given value is infinite or not?
[A]Infinite()
[B]isInfinite()
[C]checkInfinite()
[D]None of the mentioned
Show Answer
Correct Answer: isInfinite()
Notes:
Answer: b
Explanation: isInfinite() methods returns true if the specified value is an infinite value otherwise it returns false.
461). Which of these exceptions is thrown by compareTo() method defined in a double wrapper?
[A]IOException
[B]SystemException
[C]CastException
[D] ClassCastException
Show Answer
Correct Answer: ClassCastException
Notes:
Answer: d
Explanation: compareTo() methods compare the specified object to be double, if it is not then ClassCastException is thrown.
462). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.5);
boolean x = i.isNaN();
System.out.print(x);
}
}
[A]true
[B]false
[C]0
[D]1
Show Answer
Correct Answer: false
Notes:
Answer: b
Explanation: i.isNaN() method returns returns true if i is not a number and false when i is a number. Here false is returned because i is a number i:e 257.5.
Output:$ javac Output.java
$ java Output
false
463). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.578);
int x = i.intValue();
System.out.print(x);
}
}
Show Answer
Correct Answer: 257
Notes:
Answer: d
Explanation: i.intValue() method returns the value of wrapper i as a Integer. i is 257.578 is double number when converted to an integer data type its value is 257.
Output:
$ javac Output.java
$ java Output
257
464). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.578123456789);
float x = i.floatValue();
System.out.print(x);
}
}
[A]0
[B]257.0
[C]257.57812
[D]257.578123456789
Show Answer
Correct Answer: 257.57812
Notes:
Answer: c
Explanation: floatValue() converts the value of wrapper i into float, since float can measure till 5 places after decimal hence 257.57812 is stored in floating point variable x.
Output:
$ javac Output.java
$ java Output
257.57812
465). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
Double y = new Double(257.57812);
Double i = new Double(257.578123456789);
try
{
int x = i.compareTo(y);
System.out.print(x);
}
catch(ClassCastException e)
{
System.out.print("Exception");
}
}
}
[A]0
[B]1
[C]Exception
[D] None of the mentioned
Show Answer
Correct Answer: 1
Notes:
Answer: b
Explanation: i.compareTo() methods two double values, if they are equal then 0 is returned and if not equal then 1 is returned, here 257.57812 and 257.578123456789 are not equal hence 1 is returned and stored in x.
Output:
$ javac Output.java
$ java Output
1