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
String s1 = "45.50"; String s2 = "54.50"; double d1=Double.parseDouble(s1); double d2=Double.parseDouble(s2); int x= (int)(d1+d2);What is value of x?
The method to convert a lowercase character to uppercase is:
- String.toUpperCase( )
- Character.isUppercase( char )
- Character.toUpperCase( char )
- toUpperCase ( )
State the data type and value of res after the following is executed:
char ch = '9'; res= Character.isDigit(ch);