3:21 pm - Sunday March 20, 3132

Wrapper Class Interview Question

Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

Wrapper Class Interview Question


1.What are wrapper classes?

Integer, Character, Double,Byte,Short,Boolean,Long,Float

2. What is mutable object and immutable object?

If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, €¦) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, €¦)

3.What is the basic difference between string and stringbuffer object?

String is an immutable object. StringBuffer is a mutable object.

4. What are the methods in Object?

clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString.

5. Default import statement in Java

Java.lang.*;  is automatically imported into all Java Program.

6. Why do we need wrapper classes?

A: It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper classes provide many utility methods also. Because of these resons we need wrapper classes. And since we create instances of these classes we can store them in any of the collection classes and pass them around as a collection. Also we can pass them around as method parameters where a method expects an object.

7. Do I need to import java.lang package any time? Why ?

    No. It is by default loaded internally by the JVM.

8.Can I import same package/class twice? Will the JVM load the package twice at runtime?


One can import the same package or same class multiple times. Neither compiler nor JVM complains abt it. And the JVM will internally load the class only once no matter how many times you import the same class.



Filed in: Z-A Interview Questions

No comments yet.

Leave a Reply