Wrapper Classes
11.Which statement is true about wrapper classes?
-
A. They are used for creating primitive types
-
B. They are not part of java.lang package
-
C. They allow primitives to be used as objects
-
D. They are only for Strings
They allow primitives to be used as objects
They allow primitives to be used as objects
12.Which of the following will cause a runtime exception?
Integer a = null;
System.out.println(a + 1);
-
A. 1
-
B. null
-
C. Compilation error
-
D. NullPointerException
NullPointerException
NullPointerException
13.What is the output?
Integer a = 10;
Integer b = 10;
System.out.println(a.equals(b));
-
A. true
-
B. false
-
C. Compilation error
-
D. Exception
true
true
14.Which of these is NOT a method in wrapper classes?
-
A. parseInt()
-
B. valueOf()
-
C. toBinaryString()
-
D. getWrapper()
getWrapper()
getWrapper()
15.Which line will throw a NumberFormatException?
-
A. Integer.parseInt("123")
-
B. Integer.parseInt("abc")
-
C. Integer.parseInt("12")
-
D. Integer.valueOf("10")
Integer.parseInt("abc")
Integer.parseInt("abc")