Tech Students World
Subscribe
Subscribe to get the update Newsletters. This site is updated daily. Don't miss to check what's added.
                 Technology of the Week: iPod Basics *  Help of the Week: Blu-ray Technology
Skip Navigation Links
ContactUs
StudentsLibraryExpand StudentsLibrary
ExplanationOfTechnologiesExpand ExplanationOfTechnologies
TechEducationExpand TechEducation
TechTipsExpand TechTips
UsefulStudent ResourcesExpand UsefulStudent Resources
TodaySpecialsExpand TodaySpecials
WeekSpecialsExpand WeekSpecials
                                                    
Free Downloads Skip Navigation LinksHome > Java Certification Questions-Notes > Wrapper Classes
Skip Navigation Links
Home
Buying ComputersExpand Buying Computers
CertificationsExpand Certifications
Computer BasicsExpand Computer Basics
Computer DevicesExpand Computer Devices
Computer MaintenanceExpand Computer Maintenance
Computer SettingsExpand Computer Settings
Operating SystemsExpand Operating Systems
ProcessorsExpand Processors
Using MS-WindowsExpand Using MS-Windows
Internet BasicsExpand Internet Basics
Internet ServicesExpand Internet Services
Software AttacksExpand Software Attacks
Useful Links
New Student Resources
. Student Employment
. Cover Letter
. Applying for Graduate Assistantships
. SCJP Preparation
. Applying for US Universities

Wrapper Classes in Java

                                        
Note: Here,
SOP = System.out.println("");
psvm()=public static void main(String args[])

No. Java Question Answer/Output Explanation
1 new Short ("1.0");
No Compile time error. This gives Run Time Exception with NumberFormatException. Because floating point values are not acceptable.
2 new Short ("0 x 1"); No Compile time error. This gives Run Time Exception with NumberFormatException. Because hexadecimal integer integrals are not acceptable.
3 new Short ("011"); No Compile time error. This gives Run Time Exception with NumberFormatException. The argument must be a decimal integer literal. The leading 0 of argument 011 is ignored and argument is interpreted as decimal integer integral.
4 new Short ("+1"); No Compile time error. These gives Run Time Exception with NumberFormatException. A sign of + or - are not acceptable.
5 new Float("A");
new Float ("0 x 10");
No Compile time error. This gives Run Time Exception with NumberFormatException. A string representation of hexadecimal value is not acceptable.
6 new Float ("1L"); No Compile time error. This gives Run Time Exception with NumberFormatException. Arguments of the type string cannot contain an integer type suffix l or L. A floating point suffix F, f, D or d are acceptable but suffix has no impact on result.
7 new Float ('A'); 65.0 -
8 new Float (1L); 1.0 -
9 new Float (0x10); 16.0 -
10 new Float ("010"); 10.0
11 Long.parseLong("1L");
Long.parseLong("0x10");
Long.parseLong("1.0");
Long.parseLong("+1");
No Compile time error. This gives Run Time Exception with NumberFormatException. -
12 Long.parseLong("-1"); -1 -
13 new Short("1"); 1 -
14 new Short("-1"); -1
15 new Short("011"); 11 -
16 new Short("1.0");
new Short("0x1");
new Short("+1");
No Compile time error. This gives Run Time Exception with NumberFormatException. -
17 Float.toString(1.0); Compile Time Error Cannot Resolve the symbol
18 Float.toString(1.0f); 1.0 -
19 Long i1=new long(1);
Long i2=new Long(i1);
Compile Time Error Because there is no constructor that accepts a reference to an instance of type Long. [The same rule applies for Double and Integer]
20 Boolean b1=Boolean.valueOf(true);
Boolean b2=Boolean.valueOf(true);
SOP(b1==b2);
True Boolean class contains 2 public static final Boolean instances: Boolean.FALSE wraps primitive boolean value false; Boolean.TRUE wraps primitive boolean value true. Depending on the value of the argument, Boolean valueOf method returns a reference to either Boolean.FALSE or Boolean.TRUE. Reference variables b1 and b2 are both initialized with a reference value returned by method invocation expression Boolean.valueOf(true). So, b1==b2 is true.
21 Boolean b1=Boolean.valueOf(true);
Boolean b2=Boolean.valueOf("true");
SOP(b1==b2);
True Same as above.
22 Boolean b1=new Boolean(true);
Boolean b2=new Boolean(true);
SOP(b1==b2);
false -
23 Double a=new Double(0xFFFF);
byte b=a.byteValue();
-1 -
24 Double a=new Double(0xFFFF);
short c=a.shortValue();
-1 -
25 Double a=new Double(0xFFFF);
char ch=a.shortValue();
Compile Time Error -
26 byte b1=11;
SOP(
new Integer(b1).equals(new Integer(b1)));
True -
27 byte b1=11;
SOP(
new Integer(b1).equals(new Short(b1)));
False -
28 byte b1=11;
SOP(
new Integer(b1).equals(new Byte(b1)));
False -
29 Integer a = new Integer("078");
SOP(a);
78 -
30 Integer a = new Integer("078");
SOP(b.intValue(a));
78 -
31 Boolean b1 = new Boolean ("TRUE");
Boolean b2 = new Boolean ("true");
Boolean b3 = new Boolean ("AAAA");
SOP(b1 + b2 + b3);
Compile Time Error Because + cannot be applied to Boolean.
32 Boolean b1 = new Boolean ("TRUE");
Boolean b2 = new Boolean ("true");
Boolean b3 = new Boolean ("AAAA");
SOP(" "+ b1 + b2 + b3);
truetruefalse -
33 Boolean b1 = new Boolean ("TRUE");
Boolean b2 = new Boolean ("true");
Boolean b3 = new Boolean ("AAAA");
SOP((b1 + b2 + b3).toString());
Compile Time Error -
34 Double a = new Double(Double.NaN);
Double b = new Double(Double.NaN);
SOP(a.equals(b));
True -
35 SOP(Double.NaN = =Double.NaN); False -
36 Integer i =new Integer (42);
Double d = new Double (42.0);
SOP(i.equals(d));
False -
37 Integer i =new Integer (42);
Double d = new Double (42.0);
SOP(d.equals(i));
False -
38 Integer i =new Integer (42);
Double d = new Double (42.0);
SOP(i.equals(42));
Compile Time Error -
39 Integer i =new Integer (42);
Double d = new Double (42.0);
SOP(d.equals(42));
Compile Time Error -
40 Integer i =new Integer (42);
Double d = new Double (42.0);
SOP(d.equals(42.0));
Compile Time Error -
41 Integer i =new Integer (42);
Double d = new Double (42.0);
SOP(i.equals(42.0));
Compile Time Error -
42 Integer i =new Integer (42);
Double d = new Double (42.0);
SOP(i= =d);
Compile Time Error Incomparable Types.
43 Float f = new Float(32D);
SOP(f);
32.0 -
44 byte a = 10;
Byte b = new Byte(a);
Byte c = new Byte((byte)11);
SOP(b.compareTo(c));
-1 -
45 Boolean b1 = new Boolean("TRUE");
Boolean b2 = new Boolean("True");
Boolean b3 = new Boolean("false");
SOP(b1+b2+b3);
Compile Time Error + cannot be applied to java.lang.Boolean
46 Boolean b1 = new Boolean("TRUE");
Boolean b2 = new Boolean("True");
Boolean b3 = new Boolean("false");
SOP(""+b1+b2+b3);
TRUETruefalse -
47 Boolean b1 = new Boolean("TRUE");
Boolean b2 = new Boolean("True");
Boolean b3 = new Boolean("false");
SOP(b1+b2+b3)).toString());
Compile Time Error -
48 Boolean a = new Boolean(true);
Boolean b = new Boolean(false);
SOP(a+b);
Compile Time Error + cannot be applied to Boolean
49 Boolean a = new Boolean(true);
Boolean b = new Boolean(false);
SOP((a+b).toString());
Compile Time Error -
50 Boolean a = new Boolean(true);
Boolean b = new Boolean(false);
SOP(""+a+b);
truefalse -
51 Boolean a = new Boolean(true);
Boolean b = new Boolean(false);
SOP(a+""+b);
truefalse -
52 Boolean b = new Boolean(java);
SOP(b);
Compile Time Error Cannot resolve symbol
Skip Navigation Links.     
What's New
. Blu-ray
. iPod Basics
. Doing Java Project
. Symmetric MP
. Digital Cameras
. Virus,Spyware
. Sound to WebPage
. Wi-Fi
Popular Articles
. UNIX Commands
. Software Attacks
.
Adding RAM
. US Universities
. Free Java Tutorial
. Student Jobs
. Learn Spanish
. Java Notes
Let The World Know How Knowledgeable You Are
By sharing Your Knowledge With Others
If you would like to share your knowledge relating to Technology, you can send it to us at dailyquestion@techstudentsworld.com. If it is good, it will be published in this site along with your name or picture.
                  Copyright © 2008, Techstudentsworld.com. All Rights Reserved.