2(vii)
Differentiate between boxing and unboxing.
Show SolutionHide Solution↓
Differences between boxing and unboxing are:
| Boxing | Unboxing |
|---|---|
| It is the process of converting a primitive type to its corresponding wrapper class object. | It is the process of converting a wrapper class object back to its corresponding primitive type. |
| It occurs when assigning a primitive value to a wrapper object. | It occurs when assigning a wrapper object to a primitive variable. |
| Example: int num = 10; Integer obj = num; | Example: Integer obj = 20; int num = obj; |