522). Which of these methods of Byte wrapper can be used to obtain Byte object from a string?
[A]toString()
[B]getString()
[C]decode()
[D]encode()
Show Answer
Correct Answer: decode()
Notes:
Answer: c
Explanation: decode() methods returns a Byte object that contains the value specified by string.
523). Which of the following methods Byte wrapper return the value as a double?
[A]doubleValue()
[B]converDouble()
[C]getDouble()
[D]getDoubleValue()
Show Answer
Correct Answer: doubleValue()
Notes:
Answer: a
Explanation: doubleValue() returns the value of invoking object as double.
524). Which of these is a super class of wrappers Byte and short wrappers?
[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.
525). Which of these methods is not defined in both Byte and Short wrappers?
[A] intValue()
[B]isInfinite()
[C]toString()
[D]hashCode()
Show Answer
Correct Answer: isInfinite()
Notes:
Answer: b
Explanation: isInfinite() methods is defined in Integer and Long Wrappers, returns true if specified value is an infinite value otherwise it returns false.
526). What will be the output of the following Java code?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.5);
Double x = i.MAX_VALUE;
System.out.print(x);
}
}
[A]0
[B]1.7976931348623157E308
[C]1.7976931348623157E30
[D]None of the mentioned
Show Answer
Correct Answer: 1.7976931348623157E308
Notes:
Answer: b
Explanation: The super class of Double class defines a constant MAX_VALUE above which a number is considered to be infinity. MAX_VALUE is 1.7976931348623157E308.
Output:$ javac Output.java
$ java Output
1.7976931348623157E308
527). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Double i = new Double(257.5);
Double x = i.MIN_VALUE;
System.out.print(x);
}
}
[A]0
[B]4.9E-324
[C]1.7976931348623157E308
[D]None of the mentioned
Show Answer
Correct Answer: 4.9E-324
Notes:
Answer: b
Explanation: The super class of Byte class defines a constant MIN_VALUE below which a number is considered to be negative infinity. MIN_VALUE is 4.9E-324.
Output:
$ javac Output.java
$ java Output
4.9E-324
528). What will be the output of the following Java program?
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