Java Programming - Language Fundamentals - Discussion

Discussion Forum : Language Fundamentals - General Questions (Q.No. 11)
11.
Which one is a valid declaration of a boolean?
boolean b1 = 0;
boolean b2 = 'false';
boolean b3 = false;
boolean b4 = Boolean.false();
boolean b5 = no;
Answer: Option
Explanation:
A boolean can only be assigned the literal true or false.
Discussion:
15 comments Page 1 of 2.

Akash Prajapati said:   3 years ago
Boolean is only format in true or false. And is 2byte memory Located. And Boolean s1= false. Is correct format. Boolean s1= "false" is wrong, Because boolean is not "" this use.
(1)

Bhanu said:   6 years ago
Either boolean should be true or false nor (0, 1) then why not option A is correct?

Tamisevi said:   7 years ago
Why b is not correct?

Neeraja said:   8 years ago
Option A is not correct because in boolean data type it's consists only true or false statement.

Option B also not correct because false is declared within single quotes like string.

So, Option C is right.

Vinita said:   8 years ago
Why A is not Correct? Answer me clearly.

Anurag said:   9 years ago
Option A is not correct because Boolean value cannot be 0 because it is a long value.

Option B is not correct.

Option D is not correct because there is no class Boolean.

Option E is not correct it should be "true" or "false".

Amaziane said:   1 decade ago
For the option D we can initialize a boolean with this method.

Boolean b = Boolean.FALSE;
Boolean b = Boolean.TRUE;

Upendra said:   1 decade ago
Answer: C.

Because the Java people had given some default values to all the primitive data type like for int =0; For String=null;.

Bishal said:   1 decade ago
Boolean default value is false & it also take true but not with any kind of invited comma.

Avinash said:   1 decade ago
Boolean by default false in java. In java Boolean has only two value false and true. Not (0, 1) like C.


Post your comments here:

Your comments will be displayed after verification.