Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Core Java - Interview Questions and Answers for 'Wrapper classes' - 13 question(s) found - Order By Newest | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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 Asked in 3 Companies basic   frequent | ||||
| ||||
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 | ||||
| ||||
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 Asked in 2 Companies basic   frequent | ||||
| ||||
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   boolean vs Boolean basic   rare | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
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 | ||||
| ||||
Ans. Yes | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  wrapper classes  immutable  immutability | ||||
| ||||
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  immutability classes  wrapper classes | ||||