Primitive data type & an object of wrapper class - Wrapper classes

Q.  Consider the following two statements

int x = 25;
Integer y = new Integer(33);
What is the difference between these two statements?

- Published on 17 Jul 15

a. Primitive data types
b. primitive data type and an object of a wrapper class
c. Wrapper class
d. None of the above

ANSWER: primitive data type and an object of a wrapper class
 

    Discussion

  • Prajakta Pandit   -Posted on 15 Dec 15

    - The above two statement illustrates the difference between a primitive datatype and an object of a wrapper class.

    - The first statement ' int x = 25; ' declares an int variable named x and initializes it with the value 25.

    - The second statement ' Integer y = new Integer(33); ' instantiates an integer object. The object is initialized with the value 33 and a reference to the object is assigned to the object variable y.

Post your comment / Share knowledge


Enter the code shown above:
 
(Note: If you cannot read the numbers in the above image, reload the page to generate a new one.)