What are wrapper classes

What are wrapper classes

A wrapper class is nothing but primitive wrapper class in Java is one of eight classes provided in the java.lang package which are imported by default into all Java programs. All of the primitive wrapper classes in Java are immutable.

JDK 5 introduced autoboxing of primitive types into their wrapper class object, and automatic unboxing of the wrapper objects into their primitive value the implicit conversion between the wrapper objects and primitive values.
The primitive wrapper classes and their corresponding primitive types are shown below:

Wrapper classPrimitive typeConstructor arguments
byteBytebyte or String
shortShortshort or String
intIntegerint or String
longLonglong or String
floatFloatfloat, double or String
doubleDoubledouble or String
charCharacterchar
booleanBooleanboolean or String

 

Check out all interview questions

Leave a Reply

Your email address will not be published. Required fields are marked *