417). Which of these is a wrapper for data type int?
[A]Integer
[B]Long
[C]Byte
[D]Double
Show Answer
Correct Answer: Integer
Notes:
Answer: a
Explanation: None.
418). Which of the following methods is a method of wrapper Integer for obtaining hash code for the invoking object?
[A]int hash()
[B] int hashcode()
[C]int hashCode()
[D]Integer hashcode()
Show Answer
Correct Answer: int hashCode()
Notes:
Answer: c
Explanation: None.
419). Which of these is a super class of wrappers Long, Character & Integer?
[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.
420). Which of these is a wrapper for simple data type char?
[A]Float
[B]Character
[C]String
[D]Integer
Show Answer
Correct Answer: Character
Notes:
Answer: b
Explanation: None.
421). Which of the following is method of wrapper Integer for converting the value of an object into int?
[A]bytevalue()
[B]int intValue();
[C] Bytevalue()
[D] Byte Bytevalue()
Show Answer
Correct Answer: int intValue();
Notes:
Answer: b
Explanation: None.
422). Which of these methods is used to obtain value of invoking object as a long?
[A]long value()
[B] long longValue()
[C] Long longvalue()
[D] Long Longvalue()
Show Answer
Correct Answer: long longValue()
Notes:
Answer: b
Explanation: long longValue() is used to obtain value of invoking object as a long.
423). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
char a[] = {'a', '5', 'A', ' '};
System.out.print(Character.isDigit(a[0]) + " ");
System.out.print(Character.isWhitespace(a[3]) + " ");
System.out.print(Character.isUpperCase(a[2]));
}
}
[A]true false true
[B]false true true
[C]true true false
[D]false false false
Show Answer
Correct Answer: false true true
Notes:
Answer: b
Explanation: Character.isDigit(a[0]) checks for a[0], whether it is a digit or not, since a[0] i:e ‘a’ is a character false is returned. a[3] is a whitespace hence Character.isWhitespace(a[3]) returns a true. a[2] is an uppercase letter i:e ‘A’ hence Character.isUpperCase(a[2]) returns true.
Output:$ javac Output.java
$ java Output
false true true
424). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
byte x = i.byteValue();
System.out.print(x);
}
}
Show Answer
Correct Answer: 1
Notes:
Answer: b
Explanation: i.byteValue() method returns the value of wrapper i as a byte value. i is 257, range of byte is 256 therefore i value exceeds byte range by 1 hence 1 is returned and stored in x.
Output:
$ javac Output.java
$ java Output
1
425). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
float x = i.floatValue();
System.out.print(x);
}
}
[A]0
[B]1
[C]257
[D]257.0
Show Answer
Correct Answer: 257.0
Notes:
Answer: d
Explanation: None.
Output:
$ javac Output.java
$ java Output
257.0
426). What will be the output of the following Java program?
class Output
{
public static void main(String args[])
{
Long i = new Long(256);
System.out.print(i.hashCode());
}
}
[A]256
[B] 256.0
[C]256.00
[D]257.00
Show Answer
Correct Answer: 256
Notes:
Answer: a
Explanation: None.
Output:
$ javac Output.java
$ java Output
256