Output writing for Data Type Size – Computer Sir Ki Class

Login


Lost your password?

Don't have an account ?
Register (It's FREE) ×
  

Login
[lwa]



Solved Problem #JAVA#3857    siteicon   siteicon  

Problem Statement - Output writing for Data Type Size

Find output of following data type size determination instructions using wrapper class declarations.

Integer n=12;
Double d=12.0;
Float f=12.0f;
Character c=12;
Short s=12;
Long l=12L;
Byte b=12;
System.out.println(n.SIZE);
System.out.println(d.SIZE);
System.out.println(f.SIZE);
System.out.println(c.SIZE);
System.out.println(s.SIZE);
System.out.println(l.SIZE);
System.out.println(b.SIZE);

Solution

TC++ #3857

Run Output

32 
64
32
16
16
64
8

All sizes are in number of bits

32 – For integer type
64 – For double type
32 – For float type
16 – For character type
16 – For short type
64 – For long type
8   – For byte type

Notes

  • Since the SIZE field can be used only with the wrapper class version of primitive types the program has been written in the given way.

Common Errors

  • Care needs to be taken for Long type which needs a L suffix.


Suggested Filename(s): BooleanType.java



Share

sunmitra| Created: 20-Mar-2018 | Updated: 27-Nov-2019|






Back