ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
tip   SiteMap shows list of All Categories in this site.
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
please tell me what is wrapper class in java with example ?
 Question Submitted By :: Lprasanna786
I also faced this Question!!     Rank Answer Posted By  
 
  Re: please tell me what is wrapper class in java with example ?
Answer
# 1
its a class used to convert primitive data type to user 
defined data type like Integer

for example 

public class WrapperSample1 
{
   public static void main (String args[])
   {
      int iVal = 100;
      long lVal = 200;
      float fVal = 300;
      double dVal = 400;

      String str = "123";

      //primitive types to corresponding wrapper objects
      Integer intVal = Integer.valueOf(iVal);
      Long lgVal = Long.valueOf(lVal);
      Double dbVal = Double.valueOf(dVal);
      Float ftVal = Float.valueOf(fVal);

      //primitive types to string objects
      str = String.valueOf(iVal);
      str = String.valueOf(lVal);
      str = String.valueOf(fVal);
      str = String.valueOf(dVal);

      //wrapper Objects to corresponding primitive types
      iVal = intVal.intValue();
      lVal = lgVal.longValue();
      fVal = ftVal.floatValue();
      dVal = dbVal.doubleValue();

      //String to primitive types
      iVal = Integer.parseInt(str);
      lVal = Long.parseLong(str);
      fVal = Float.parseFloat(str);
      dVal = Double.parseDouble(str);

      //string to wrapper objects
      intVal = Integer.valueOf(str);
      lgVal = Long.valueOf(str);
      ftVal = Float.valueOf(str);
      dbVal = Double.valueOf(str);
  }
}
 
Is This Answer Correct ?    12 Yes 2 No
Vikneswarank
[Jadian]
 
  Re: please tell me what is wrapper class in java with example ?
Answer
# 2
By the help of Wrapper classes we can convert a primitive
type into Object type . These are the static classes and
provides methods for this .
 
Is This Answer Correct ?    5 Yes 0 No
Naresh Tuhania
 
 
 
  Re: please tell me what is wrapper class in java with example ?
Answer
# 3
The wrapper class used for To convert Primitive data Type 
in to User defined data Type and also  Collection class 
contain all user defined data type this user defined data 
type convert into primitive data type
 
Is This Answer Correct ?    0 Yes 0 No
Srinu
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is an abstract class and abstract method?  4
Difference between String and String Buffer?  3
Can we place the any object to key attribute of HashMap<key,value>? HCL3
write a class to input 2 points by the user & check the line maked by the points is horizontal,vertical or rectangle?  1
What is the differnence between String Buffer and String builder despite having knowledge that String builder is faster than String Buffer and last one is threadsafe.please tell another important difference.  3
What services that container provides?  1
What is difference between static method and static variable?  6
What is the USE of Null interfaces ??...if thers nothing inside these interfaces how are they used and WHy are they used ???? No 1 has given a proper description yet  1
How are this() and super() used with constructors?  4
what is dynamic method dispatch ? Fidelity11
how do you store phone numbers using java collections Bosch4
Which all r Final classes in java except string?  3
If you are reviewing the code of your team members, what points will you look at, assuming the performance of the application is not so great KPIT2
Hey buddy.. can you please tell me about the use of marker interface? And is there any link between marker interface and factory methods? Thanks in advance.  2
what is the need of the Ajax? iFlex5
hi to all. well can you please tell me that why String class is immutable? Thanks in advance. Huawei3
what is polymorphism with example?types of polymorphism? HP6
what is d difference between deep cloning and shallow cloning in core java? Satyam2
we have two threads..both the threads are reading the data.. is there any need of synchronization there?...justify it? IBM4
What is the difference between error and exception and explain in simple words not whatever is given in the book.  6
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com