Java - Data Types - Interview Questions and Answers on Boolean / boolean

Q1.  Variable of the boolean type is automatically initialized as?

Ans. The default value of the boolean type is false.

Q2. What is the difference between boolean and Boolean ?

Ans. boolean is a promitive type whereas Boolean is a wrapper class.

Q3.  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

Q4.  Which data types are supported by JSON ?

Ans. Number

Q5.  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

Q6. What is the use of Boolean method valueOf(String s) ?

Ans. This method returns the boolean value for the specified string. The returned value represents a true value if the string argument is not Null and is equal, ignoring case, to the string "true".

Subscribe to Java News and Posts. Get latest updates and posts on Java from
Enter your email address:
Delivered by FeedBurner
comments powered by Disqus