Java - Interview Questions and Answers on Wrapper Classes

Q1.  What are the Wrapper classes available for primitive types ?

Ans. boolean  - java.lang.Boolean
byte - java.lang.Byte
char - java.lang.Character
double - java.lang.Double
float - java.lang.Float
int - java.lang.Integer
long - java.lang.Long
short - java.lang.Short
void - java.lang.Void

Q2.  What are wrapper classes ?

Ans. They are wrappers to primitive data types. They allow us to access primitives as objects.

Q3.  Difference between boolean and Boolean ?

Ans. boolean is a primitive type whereas Boolean is a class.

Q4.  Explain Autoboxing ?

Ans. Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes

Q5.  What are Wrapper Classes ? What are Primitive Wrapper Classes ?

Ans. A wrapper class is any class which "wraps" or "encapsulates" the functionality of another class or component. A Wrapper Class that wraps or encapsulates the primitive data type is called Primitive Wrapper Class.

Q6.  What Design pattern Wrapper Classes implement ?

Ans. Adapter.

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus