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                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
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 ?    5 Yes 2 No
Vikneswarank
[Jadian]
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
long d =10;int i =0;i=d; /// is this possible? If d is very long number (10 digits or some thing) then?  1
What is the protocol is used in type4 driver? CMC1
How are Java source code files named?  2
If all the methods in abstract class are declared as abstract then what is difference between abstract class and in interface? Synechron4
Inorder to specify a container?s layout, which method is used?  1
what is mean by overriding in which situation we wil use? Atlas-Systems4
What are wrapped classes?  5
Without creating a new object, How you can retrieve a String or other object?  1
when we have to use final class in java?  2
int a=1; float b=1.0; System.out.println(a==b); Honeywell7
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.  2
What is a reflection package?  2
how to call One constructor from another; Innodata-Isogen4
whats the life cycle of jsp Satyam2
What is the frontend and backedn in Java? TCS2
What is meant by serialisation and deserialisation?  2
What is thin driver and thick driver. why it is called so? Logisoft1
wht is customised exception? Prudential1
what are the oops concept in java explain with real time examples Tech-Mahindra2
Explain final, finalize() and finally?  4
 
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