What is a Wrapper class?

Answer Posted / sandeep sagala

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 auto boxing 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.This Number
class is subject to the object class

Is This Answer Correct ?    6 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

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

588


How do you square a number?

558


Why are the destructors for base class and derived class called in reverse order when the program exits

1672


State the difference between strings and arrays.

565


Write a program to search a number in the given list of numbers.

614






How is a structure different from array ?

556


what is abstract class in Java?

621


Why do we need singleton?

516


Who is the owner of java?

513


What is an off by one error in java?

473


What is reverse function?

550


How do you use parseint in java?

488


What is map java?

495


What is <> used for in java?

650


What is the difference between jdk and jre?

582