In: Computer Science
1. Which of the following can be treated as a Boolean expression?
A. an int expression
B. any of these
C. the result of a comparison(such as <or>)
D. a float expression
ANSWER: B
Explanation:
Boolean data type is return either True or False. It's a logical statement. Boolean expression can compare any type of data but the condition is that the expression have the same basic data type. you can perform expression like a<=b , a.=b , a!=b , less than, greater than etc...
Let's talk of your quetion:
Here option A an int expression lets take an example
Suppose we have two int value 5 and 6 we want to check is equal or not. so we can write like this
5==6
it's return FALSE because 5 is not equal to 6. So option A is correct.
option c
Suppose we have two int value 10 and 16 we want to check is less than or not. so we can write like this
10<16
it's return TRUE because 10 is less than to 16. So option c is also correct.
option D
Suppose we have two float value 0.1 and 1.6 we want to check is equal or not. so we can write like this
0.1==1.6
it's return FALSE because 10 is less than to 16. So option D is also correct.
So the ans is B any of these.
2. Assuming the variable x contains an integer value what will the result of the following statement be: if x<0 or x>=0.
A. True
B. False
C. Sometimes true and sometimes false
D. A "math domain" error will occur
ANSWER: A
Explanation:
Lets take example here we first take x=0 so its return TRUE
Now we take x=1 so its return TRUE
Now we take negative value which is x = -5 It's also return TRUE
Here you take whatever value its always return TRUE because here in if statement give OR so it's check if any one condition either x<0 or x>=0 is satisfied it Return TRUE.
so the answer of your question is option A