Java - Interview Questions and Answers for 'Wrapper classes' | Search Java Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com
Share

Search Java Interview Questions


 2137 questions in repository.
 There are more than 200 unanswered questions.
Click here and help us by providing the answer.
Label / Company      Label / Company / Text

   



Interview Questions and Answers for 'Wrapper classes' - 13 question(s) found - Order By Newest

 Q1. What are the Wrapper classes available for primitive types ?Core Java
Anonymous
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

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java5   data types   wrapper classes   adapter design pattern        rare


 Q2. What are wrapper classes ?Core Java
Anonymous
Ans. They are wrappers to primitive data types. They allow us to access primitives as objects.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   data types   wrapper classes     CSL  Xoriant  Webilent      basic        frequent


 Q3. Difference between boolean and Boolean ?Core Java
Anonymous
Ans. boolean is a primitive type whereas Boolean is a class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   oops   wrapper classes      basic        rare


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

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   java5   autoboxing   wrapper classes     Cognizant (CTS)      basic        frequent


 Q5. What are Wrapper Classes ? What are Primitive Wrapper Classes ?
Core Java
Anonymous
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.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   wrapper classes   primitive wrapper classes


 Q6. What Design pattern Wrapper Classes implement ?Design
Anonymous
Ans. Adapter.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   wrapper classes   adapter design pattern   design pattern


 Q7. Will this code give error if i try to add two heterogeneous elements in the arraylist. ? and Why ?

List list1 = new ArrayList<>();
list1.add(5);
list1.add("5");
Admin
info@buggybread.com
Ans. If we don't declare the list to be of specific type, it treats it as list of objects.

int 1 is auto boxed to Integer and "1" is String and hence both are objects.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   collections   arraylist   list   autoboxing   wrapper classes      expert        rare


 Q8. Can we compare Integers by using equals() in Java ?Core Java
Admin
info@buggybread.com
Ans. Yes for the Wrapper class Integer but not for the primitive int.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   wrapper classes   equals


 Q9. Is this valid in Java ?

Long x = new Long ("42");
Core Java
Admin
info@buggybread.com
Ans. Yes. Long wrapper class has overloaded constructor which takes String as input and then translate it to the long value and stored it as long.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     java   wrapper classes   long wrapper class   long



Do you think these are the Best Java Frameworks ?

OpenXavaSPRING MVCApache StripesCheck everything
that is Best in Java

Click Here



 Q10. What is Boxing conversion ?Core Java2017-06-06 12:31:36

Ans. Boxing conversion converts expressions of primitive type to corresponding expressions of reference type.

For example

boolean to Boolean
long to Long
double to Double

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     data type  boxing  wrapper classes


 Q11. Does Wrapper classes produces immutable objects ? Core Java2017-08-08 09:46:33

Ans. Yes

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     wrapper classes  immutable


 Q12. What are the benefits of using Wrapper classes over primitive types ?Core Java2017-08-24 21:35:53

Ans. With Collection classes , we cannot use primitive types. Moreover for any class using generic types, we cannot use primitive types.

They add more functionality by means of additional methods.

As their reference can be null , they offer consistent check for uninitialized state.

They facilitate caching and reuse by means of constant Pools.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     wrapper classes  benefits of wrapper classes over primitives


 Q13. Is immutability an advantage with Wrapper classes over primitive types ? Core Java2017-08-24 21:43:19

Ans. There is no concept of de referencing with primitive types and hence they are implicitly immutable. Having wrapper classes as mutable offers disadvantages compared to primitive types. Wrapper classes being immutable offer similar advantage as primitive types.It actually overshadows the disadvantage wrapper class could have if they are immutable.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like      Discuss      Correct / Improve     immutable classes  wrapper classes




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



comments powered by Disqus
 

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked:
         

X Close this

X Close this

Help Us Improve.
Please share your
interview experience.

Company Name:   


Questions Asked: