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

Explain about strings in java?

818


Explain public static void main(string args[]).

847


Why deletion in linkedlist is fast than arraylist?

767


What is the difference between serializable and externalizable interface?

787


Why do you canvas?

781


What comes to mind when someone mentions a shallow copy in java?

883


What is function and method in java?

723


What is ‘is-a ‘ relationship in java?

793


Can java hashmap have duplicate keys?

708


What is the biggest integer?

802


Mention the default values of all the elements of an array defined as an instance variable.

732


How does java pattern compile work?

741


What is meant by oops concept in java?

734


What is anti pattern in programming?

724


What is anagram in java?

712