Java - Data Types / Wrapper Classes - Interview Questions and Answers on Long

Q1.  What are the Wrapper classes available for primitive types ?

Ans. boolean  - java.lang.Boolean
byte - java.lang.Byte
char - java.lang.Character
double - java.lang.Double
float - java.lang.Float
int - java.lang.Integer
long - java.lang.Long
short - java.lang.Short
void - java.lang.Void

Q2.  Difference between long.Class and Long.TYPE ?

Ans. They both represent the long primitive type. They are exactly the same.

Q3.  What are the default or implicitly assigned values for data types in java ?

Ans. boolean ---> false
byte ----> 0
short ----> 0
int -----> 0
long ------> 0l
char -----> /u0000
float ------> 0.0f
double ----> 0.0d
any object reference ----> null

Q4.  Is this valid in Java ?

Long x = new Long ("42");

Ans. Yes. Long wrapper class has overloaded constructor which takes String as input and then translate it to the long value and stored it as long.

Q5.  What is the size of long data type ?

 a. 16 bit
 b. 32 bit
 c. 64 bit
 d. 128 bit

Ans. 64 bit

Q6. What is the package name for Long class?

Q7. Which is the Parent Class of Long class?