Boolean

Practice Questions

Computer Science › Boolean

Questions
7
1

Consider the code below:

int[] vals = {841,-14,1,41,49,149,14,148,14};

boolean[] bools = new boolean[vals.length];

for(int i = 0; i < vals.length; i++) {

bools[i] = vals[i] > 20 && vals[i] % 2 == 0;

}

for(int i = 0; i < bools.length; i++) {

if(bools[i]) {

System.out.println(vals[i]);

}

}

What is the output of the code above?

2

Convert the decimal number 67 to binary.

3

In the following equation, considering the boolean variables x, y, and z, which of the following combinations of values will evaluate to true?

(x\,\&\&\,!y)\,||\,((!x\,||\,z)\,\&\&\,!(y\,||\,z))

4

How do we set a method to return a Boolean in Swift(iOS)?

5

int j=6;

int k=0;

int l=2;

int c = (j|k) & l;

What is the value of c?

6

#include

using namespace std;
bool bigger(int x, int y)
{
if (x>y)
return true;
else
return false;
}
int main()
{

bool test;
test!=bigger(10,7);
cout<<test;
}

What will be the value of test after the previous code is run?

7

In Swift (iOS), define an unwrapped boolean.

Return to subject