What is a Wrapper class?

Answer Posted / darshan

A primitive wrapper class in the Java programming language
is one of eight classes provided in the java.lang package to
provide object methods for the eight primitive types. All of
the primitive wrapper classes in Java are immutable. J2SE
5.0 introduced autoboxing of primitive types into their
wrapper object, and automatic unboxing of the wrapper
objects into their primitive value—the implicit conversion
between the wrapper objects and primitive values.

Wrapper classes are used to represent primitive values when
an Object is required. The wrapper classes are used
extensively with Collection classes in the java.util package
and with the classes in the java.lang.reflect reflection
package.

The primitive wrapper classes and their corresponding
primitive types are:

Primitive type Wrapper class Constructor Arguments
byte Byte byte or String
short Short short or String
int Integer int or String
long Long long or String
float Float float, double or String
double Double double or String
char Character char
boolean Boolean boolean or String

The Byte, Short, Integer, Long, Float, and Double wrapper
classes are all subclasses of the Number class.

Is This Answer Correct ?    27 Yes 10 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

When does an object becomes eligible for garbage collection in java?

824


What are variable names?

734


What flag up means?

804


Is sizeof a preprocessor?

757


What are the differences between getting and load method?

759


Tell me about your ability to work under pressure

1968


What are desktop procedures?

808


Can a boolean be null java?

753


Define class?

730


How big is a gigabyte?

841


What is scope & storage allocation of static, local and register variables? Explain with an example.

817


Where are the local variables stored?

790


How do you get the length of a string in java?

752


Are registers volatile?

725


What is a jagged array in java?

796