KnowledgeBoat Logo
|

Computer Applications

Assertion (A): In Java, assigning an int value to an Integer object is valid.

Reason (R): Java automatically converts primitive data types to their corresponding wrapper classes, which is called Autoboxing.

Java Library Classes

1 Like

Answer

Both Assertion (A) and Reason (R) are true and Reason (R) is a correct explanation of Assertion (A)

Reason — Java allows automatic conversion of an int to an Integer using Autoboxing.

Example:

Integer num = 10;  // Autoboxing: int → Integer

Answered By

1 Like


Related Questions