Data Types Interview Questions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 7

KODNEST PH:7411615623 hello@kodnest.

com

1. In what format is Integer data stored in memory unit?


(base-2 format)
2. In what format is real number data stored in memory unit?
(IEEE format)
3. Which data types in Java are used to handle Integer data?
(byte, short, int and long)
4. In what format is still picture data stored in memory unit?
(.jpeg format and .gif format)
5. What are the different types of data in real world?
(character type data, integer type data, real number type
data, yes/no type data, still picture type data, audio and
video type data)
6. In what format is video data stored in memory unit?
(.mp4 format and .avi format)
7. What is the real number data by default treated in Java?
(double)
8. 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)
10. Does Java follow ASCII or UNICODE ? Why?
(UNICODE. Because UNICODE supports all the symbols of
all the languages across the world)
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)

1
KODNEST PH:7411615623 hello@kodnest.com

13. What is the range of data that can be stored in byte data type?
(-128 to +127)
14. In what format is audio data stored in memory unit?
(.mp3 format)
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)
17. Is zero a positive number or negative number in programming?
Why?
(Zero is a positive number, because the most significant bit in the
positive number is zero)
18. Who initiates the process of executing a program?
(OS)
19. 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)
20. What is the range of double?
(-1.7e-308 to +1.7e+308)
21. Why does Java provide four data types to manage Integer
type data?
(Because in real world integer data exists in varying magnitudes)
22. Why does Java provide two data types to manage real number
type data?
(for less precision and higher precision hint: double provides
more accuracy than float)

2
KODNEST PH:7411615623 hello@kodnest.com

23. Why should data be stored in form of 0s and 1s in the memory?


(because every memory device can store only 0’s and 1’s)
24. How is audio type data handled in Java?
(Using in built classes)
25. How is video type data handled in Java?
(Using in built classes)
26. How is still picture type data handled in Java?
(Using in built classes)
27. How many bytes are allocated for boolean data type in Java?
(It is OS dependent or JVM dependent)
28. What is the range of float?
(-3.4e-038 to +3.4e+038)
29. What are the different data types in Java?
(byte, short, int, long, float, double, boolean, char)
30. How is data stored in the memory unit?
(in the binary form)
31. Which data types in Java are used to handle real number data?
(float and double)
32. In what format is character data stored in memory unit?
(UTF-16 or UTF-32)
33. In what format is yes/no data stored in memory unit?
(It is JVM dependent)
34. What is the range of data that can be stored in int data type?
( -2147483648 to 2147483647)
35. How can you convert double data type to float data type in
Java?
(By explicit typecasting)

3
KODNEST PH:7411615623 hello@kodnest.com

36. How many bytes are allocated for byte data type in Java?
(1 byte)
37. How many bytes are allocated for double data type in Java?
(8 bytes)
38. How many bytes are allocated for int data type in Java?
(4 bytes)
39. Which special characters may be used as the first character of
an identifier?
(_ and $)
40. Why is ASCII format forcefully stored as 8-bit format?
(Because minimum memory that is allocated is 1 Byte i.e. 8bits)
41. What is UTF?
(Universal Transactional Format)
42. What is meant by rounding towards zero in integer division?
(truncation, i.e. fractional portion is truncated and only the
integer portion is retained)
43. Are true and false keywords?
(yes)
44. What is numeric promotion?
(When data of a smaller magnitude is placed within a memory
location of a larger magnitude, it is called as numeric promotion.
Implicit typecasting is also called as numeric promotion.)
45. Give the implicit typecasting chart or numeric promotion
chart?
(Refer class notes)

46. Which Java operator is right to left associative?


(Assignment operator (=))

4
KODNEST PH:7411615623 hello@kodnest.com

47. Can a double value be cast to a byte?


(Yes.)
48. Express double a = 123.45 in scientific notation?
(double a = 1.2345E+2)
49. Can we use underscore in a literal?
(Yes.)
50. Can we create binary literals in Java?
(Yes. Using a prefix 0b)
51. How do we make a project coded in Java a pure OOP project?
(Using wrapper classes)
52. What happens if a larger magnitude data is assigned to a
value of a data type which cannot handle it?
(Overflow or loss of precision occurs)
53. Should type casting be performed explicitly?
(Depends upon whether implicit or explicit typecasting is
performed)
54. Does type casting reduce the precision of the data?
(Depends upon whether implicit or explicit typecasting is
performed)
55. What is the role of formats in data types?
(It is used to convert real world data into 0s and 1s so that it can
be stored in the memory unit)
56. What is a variable?
(It is a reserved memory location into which a value can be
stored)
57. What are the types of variables available in Java?
(Local variables, instance variables, reference variables and static
variables)

5
KODNEST PH:7411615623 hello@kodnest.com

58. How is a negative number stored in Byte data type?


(2’s compliment)
59. What does a prefix 0 indicate in a literal?
(Octal)
60. What does a prefix 0x indicate in a literal?
(Hexadecimal)
61. What is the default value of long?
(0L)
62. What is the default value of double?
(0.0)
63. What is the default value of char?
(‘\u0000’)
64. How is a binary literal created in Java?
(Using the prefix 0b)
65. Identify valid and invalid literals?
long debitCardNumber = 1234_5678_9012_3456L;
long ssn = 999_99_99999L;
float p = 3.14_25F;
long hexa = 0xFE_EC_DE_5E;
long hexa2 = 0xCAFF_BABE;
long hexa3 = 0x8fff_ffff_ffff_ffffL;
byte bin = 0b0010_010101;
long bytes = 0b110010_0101001_10010100_110010;
float pi1 = 3_.1475F;
float pi2 = 3._141F;
long ssn1 = 999_99_99999_L;
int x1 = 5_3;
int x2 = 53_;

6
KODNEST PH:7411615623 hello@kodnest.com

int x3 = 5_______3;
int x4 = 0_x53;
int x5 = 0x_53;
int x6 = 0x5_3;
int x7 = 0x53_;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy