Data Type Important Question
Data Type Important Question
R.PUNITH KUMAR
KODNEST® | BENGALURU
KODNEST® WWW.KODNEST.COM PH:8095000123
5.What is the range of data that can be stored in long data type?
(-9223372036854775808L to 9223372036854775807L) )
9. How many bytes are allocated for short data type in Java?
(2 bytes)
11. How many bytes are allocated for long data type in Java? (8
bytes)
12. How many bytes are allocated for float data type in Java? (4
bytes)
pg. 1
KODNEST® WWW.KODNEST.COM PH:8095000123
13. What is the range of data that can be stored in byte data type?
(-128 to +127)
15. What is the range of data that can be stored in short data type?
(-32768 to +32767)
16. How many bytes are allocated for char data type in Java?
Why? (2 bytes, because java follows UNICODE)
18. Why does Java provide primitive data types in spite of the fact
that it makes it only 99% OOP? (Because primitive data types are
fast in execution when compared to wrapper classes)
19. What is the range of double? (-1.7e to the power -308 to +1.7e
to the power +308)
22. What are the different primitive data types in Java? (byte,
short, int, long, float, double, boolean, char)
pg. 2
KODNEST® WWW.KODNEST.COM PH:8095000123
23. How is data stored in the memory unit? (in the binary form)
24. Which data types in Java are used to handle real number
data? (float and double)
26. Why did UNICODE come into existence? (Because ASCII did
not support symbols of all the languages in the world)
27. What is the range of data that can be stored in int data type?( -
2147483648 to 2147483647)
28. How can you convert double data type to float data type in
Java? (By explicit typecasting (float=(float)24.17; or by putting
suffix f(24.17f;))
29. How many bytes are allocated for byte data type in Java? (1
byte)
30. How many bytes are allocated for double data type in Java? (8
bytes)
40. How many bytes are allocated for int data type in Java? (4
bytes)
pg. 3
KODNEST® WWW.KODNEST.COM PH:8095000123
47. What are the rules associated with the usage of underscore in
a literal? (Refer class notes)
pg. 4
KODNEST® WWW.KODNEST.COM PH:8095000123
52. What is the difference between char literal and string literal?
(character literal is data which is enclosed within single quotes
where as String literal is data which is enclosed within double
quotes)
55. Can we create binary literals in Java? (Yes. Using a prefix 0b)
57. What is the role of wrapper classes in Java? (To code purely
objected oriented projects.)
pg. 5
KODNEST® WWW.KODNEST.COM PH:8095000123
pg. 6
KODNEST® WWW.KODNEST.COM PH:8095000123
pg. 7
KODNEST® WWW.KODNEST.COM PH:8095000123
// OK (decimal literal)
int a1 = 5_2;
// Invalid: cannot put underscores
// At the end of a literal
int a2 = 52_;
// OK (decimal literal)
int a3 = 5_______2;
pg. 8