Q:
Java find output programs (Autoboxing & Unboxing) | set 1
belongs to collection: Java find output programs
Java find output programs
- Java find output programs (Data Types) | set 1
- Java find output programs (Data Types) | set 2
- Java find output programs (Data Types) | set 3
- Java find output programs (Operators) | set 1
- Java find output programs (Operators) | set 2
- Java find output programs (Operators) | set 3
- Java find output programs (if else) | set 1
- Java find output programs (if else) | set 3
- Java find output programs (switch case) | set 1
- Java find output programs (switch case) | set 2
- Java find output programs (switch case) | set 3
- Java find output programs (Loops) | set 1
- Java find output programs (Loops) | set 2
- Java find output programs (Loops) | set 3
- Java find output programs (Arrays) | set 1
- Java find output programs (Arrays) | set 2
- Java find output programs (Arrays) | set 3
- Java find output programs (this Keyword) | set 1
- Java find output programs (final Keyword) | set 1
- Java find output programs (final Keyword) | set 2
- Java find output programs (static Keyword) | set 1
- Java find output programs (static Keyword) | set 2
- Java find output programs (Parameter Passing) | set 1
- Java find output programs (Class and Objects) | set 1
- Java find output programs (Class and Objects) | set 2
- Java find output programs (Class and Objects) | set 3
- Java find output programs (Constructor & Destructor) | set 1
- Java find output programs (Constructor & Destructor) | set 2
- Java find output programs (Constructor & Destructor) | set 3
- Java find output programs (Inheritance) | set 1
- Java find output programs (Inheritance) | set 2
- Java find output programs (Inheritance) | set 3
- Java find output programs (Interface) | set 1
- Java find output programs (Interface) | set 2
- Java find output programs (Interface) | set 3
- Java find output programs (Overloading) | set 1
- Java find output programs (Overloading) | set 2
- Java find output programs (Overriding) | set 1
- Java find output programs (Overriding) | set 2
- Java find output programs (Overriding) | set 3
- Java find output programs (Exception Handling) | set 1
- Java find output programs (Exception Handling) | set 2
- Java find output programs (Exception Handling) | set 3
- Java find output programs (Enumeration) | set 1
- Java find output programs (Enumeration) | set 2
- Java find output programs (Autoboxing & Unboxing) | set 1
- Java find output programs (Autoboxing & Unboxing) | set 2
- Find output programs (Java String class)
- Find Output of Java program - 1 (Mixed topics)
- Find Output of Java program - 2 (Mixed topics)
- Java find output programs (if else) | set 2
Answer Question 1:
Output:
Explanation:
In the above program, we created a class BoxingEx that contains the main() method. The main() method is the entry point for the program. Here, we created a local variable intVar initialized with 50.
Object Obj = intVar;
In the above statement, we perform Autoboxing of variable intVar and assigned to the object Obj, and then we assigned the value 20 into variable intVar, and then print the value of intVar and Obj on the console screen.
Answer Question 2:
Output:
Explanation:
The above program will generate an error because of the below statement,
result = intVar + Obj;
Here, we added variable intVar with object Obj. But we cannot access add integer variable with object Obj.
Answer Question 3:
Output:
Explanation:
In the above program, we created two integer variables intVar and result initialized with 50 and 0 respectively.
Integer Obj = intVar; intVar = 100;
In the above statement we autobox the variable intVar into object of Wrapper Integer class, and assign value 100 to the variable intVar Then we added intVar and Obj and assign the result into result variable, and finally print the variable result on the console screen.
Answer Question 4:
Output:
Explanation:
In the above program, we created two integer variables intVar and result initialized with 150 and 0 respectively.
Object Obj = intVar; intVar = 100;
In the above statement, we autobox the variable intVar into object, and assign value 100 to the variable intVar.
result = intVar + (int)Obj;
In the above statement, we typecast object Obj into integer and added to the variable intVar and assigned the result to the variable result. After that print the value of the result variable on the console screen.
Answer Question 5:
Output:
Explanation:
The above program will generate syntax errors because of the below statements,
float floatVar = 12.5; floatVar = 13.6;
In the both above statement, we assigned double value instead of float value, here we need to use character 'F' in the suffix of a given value. The correct code is given below,
float floatVar = 12.5F; floatVar = 13.6F;
need an explanation for this answer? contact us directly to get an explanation for this answer