English

Differentiate between a wrapper class and a Primitive Type.

Advertisements

Question

Differentiate between a wrapper class and a Primitive Type.

Distinguish Between
Advertisements

Solution

Wrapper Class

Primitive Type

1. A wrapper class is a predefined class in Java that represents a primitive data type as an object.

1. A primitive type is a basic built-in data type in Java that is used to store simple values.

2. A wrapper class represents a primitive value within an object and allows it to be treated as an object.

2. A primitive type stores its actual value directly without creating an object.

3. A wrapper class provides various predefined methods for converting, comparing and manipulating data.

3. A primitive type does not contain methods for converting or manipulating its values.

4. A wrapper class generally requires more memory because it represents data in the form of an object.

4. A primitive type generally requires less memory because it stores only the basic data value.

5. A wrapper class can hold a null reference to represent the absence of an object.

5. A primitive type cannot hold a null value because it stores an actual primitive value.

6. Wrapper classes are useful when working with collections and methods that require objects.

6. Primitive types are useful for performing basic calculations and storing simple data efficiently.

7. Examples: Integer, Double, Character and Boolean are wrapper classes in Java.

7. Examples: int, double, char and boolean are primitive data types in Java.

shaalaa.com
  Is there an error in this question or solution?
Chapter 5: Primitive Values, Wrapper Classes, Types and Casting - EXERCISE [Page 112]

APPEARS IN

Dheeraj Mehrotra Computer Science [English] Class 12
Chapter 5 Primitive Values, Wrapper Classes, Types and Casting
EXERCISE | Q 6. | Page 112
Advertisements
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×