Java Programming - Language Fundamentals - Discussion
Discussion Forum : Language Fundamentals - General Questions (Q.No. 11)
11.
Which one is a valid declaration of a boolean?
Answer: Option
Explanation:
A boolean can only be assigned the literal true or false.
Discussion:
15 comments Page 1 of 2.
Vineet said:
1 decade ago
Please also define the resion of other option, why is not corret.
Saurav said:
1 decade ago
Why is option A not correct?
Sweety said:
1 decade ago
Boolean always returns true or false. So option A can't be !
Akanksha said:
1 decade ago
Option B is have single quotes which is for a string so its wrong.
Option D is compilation error.
Option E is also compilation error as no is not any keyword.
Option D is compilation error.
Option E is also compilation error as no is not any keyword.
Kirti said:
1 decade ago
Option D is not correct because Boolean is not correct it must be Boolean.
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.
Bishal said:
1 decade ago
Boolean default value is false & it also take true but not with any kind of invited comma.
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;.
Because the Java people had given some default values to all the primitive data type like for int =0; For String=null;.
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;
Boolean b = Boolean.FALSE;
Boolean b = Boolean.TRUE;
Anurag said:
1 decade 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".
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".
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers