Search Header Logo

Chapter 5-Boolean Expressions and If Statements-Ch 5 Rev. Drill

Authored by THOMAS HARRIS

Computers

9th - 12th Grade

Chapter 5-Boolean Expressions and If Statements-Ch 5 Rev. Drill
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

2 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Consider the following code segment:

for (int i = 200; i > 0; i /=3)

{

if (i % 2 == 0)

System.out.print (i + " ") ;

}

What is the output as a result of executing the code segment?

(A) 200 66 22 7 2

(B) 66 22 7 2

(C) 200 66 22 2

(D) 200 66 22

(E) 7

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

2. Suppose p and q are declared as boolean variables and have been initialized to unknown truth values.

What does the following boolean expression evaluate to?

(p && ! q) | | (p && q)

(A) The expression always evaluates to the same value as p.

(B) The expression always evaluates to the same value as q.

(C) The expression always evaluates to the same value as true.

(D) The expression always evaluates to the same value as false.

(E) The expression only evaluates to true if p and q have opposite truth values.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?