MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

ALGORITHMS

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
A boolean is ____
A
A whole number
B
A number with a decimal part
C
Letters, numbers or punctuation
D
True or False
Explanation: 

Detailed explanation-1: -A Boolean value represents a truth value; that is, TRUE or FALSE. A Boolean expression or predicate can result in a value of unknown, which is represented by the null value.

Detailed explanation-2: -Booleans ¶ The bool type only has two values, and is used to express a truth value. It can be either true or false .

Detailed explanation-3: -Using the strict equality operator (===) As users know Boolean data type has two values which are true and false, and we will compare the variable with both Boolean values. If one of the match conditions returns true, the variable is of Boolean type.

Detailed explanation-4: -Constant true is 1 and constant false is 0. It is considered good practice, though, to write true and false in your program for boolean values rather than 1 and 0.

Detailed explanation-5: -false is a primitive and Boolean. FALSE is an object, so they’re not really comparable. If you assign false to a Boolean variable, like this: Boolean b = false; Java’s auto boxing occurs to convert the primitive into an object, so the false value is lost and you end up with Boolean.

There is 1 question to complete.