1. Wrapper classes provide a way to use primitive data types (int, boolean, etc..) as objects.
2. Analyse the following code which uses wrapper classes. To create a wrapper object, use the wrapper class instead of the ___________.
3. The advantage of using wrapper classes is that you can then have access to all the associated ______ that correspond to the object. E.g. intValue(), byteValue()
4. In the following example an Integer is converted to a String. What is the final output?
5. The automatic conversion of primitive data type into its corresponding wrapper class is known as autoboxing, for example, byte to Byte, char to Character, int to Integer
6. The following code shows examples of 'unboxing' which involves:
7. Read the following statements. Are both of them correct? (if so, select 'True')
8. What does the following code do?
9. Are both the following statements correct? (select 'True' if so)
10. Analyse the following code. What is the output of decode(45)?
11. What is the output of the following code?
class stringToInt
{
public static void main(String args[])
{
String s = "123";
Integer intObj = Integer.valueOf(s);
int i = obj.intValue();
i += 2;
System.out.println(i);
}
}
12. There is a wrapper class for every primitive in Java. For instance, the wrapper class for int is ______.
13. All of the wrapper classes except ________ provide two constructors: one that takes a primitive of the type being constructed, and one that takes a String representation of the type being constructed-
14. The Character class provides only ___ constructor, which takes a char as an argument-e.g. Character c1 = new Character('c');
15. Wrapper classes are useful in storing primitive data types in higher level data structures