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

Which is illegal identifier in java?

788


Can you call a method on a null object?

757


What is a line separator in java?

731


What is style and indentation?

758


What value is a variable of the string type automatically initialized?

824


Does unicode support all languages?

762


What is the static field modifier?

816


What is parameter example?

770


Does java map allow duplicates?

658


Explain importance of inheritance in java?

780


What is gc()?

746


Explain garbage collection in java?

746


What is finally in Java?

798


What is difference between static class and normal class?

750


Is a class subclass of itself?

837