Search Header Logo

Unit 3 If statements Quiz

Authored by Karen Russo

Computers

9th - 12th Grade

Used 10+ times

Unit 3 If statements Quiz
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

13 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

Pick the value that best completes the sentence: A boolean variable has _______ value(s).

only one valid

two valid

three valid

only invalid

2.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What mathematical symbol/word does the symbol && in java represent?

and

or

average

absolute value

3.

MULTIPLE CHOICE QUESTION

1 min • 1 pt

What does the symbol ! mean in a boolean expression?

Always use 0 for x

Always true

Never true

Not

4.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

If x = 5, y = 10 and z = 10, the expression

(x < y) && !(y ==z)

will return the value of _______________.

true

false

null

cannot be determined

5.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What will be the output for the following program segment?

int num = 20;

if (num > 0)

if (num % 5 == 0)

System.out.println(num);

else System.out.println(num + " is negative ");

20

4

4 is negative

20 is negative

6.

MULTIPLE CHOICE QUESTION

2 mins • 1 pt

What line of code would replace the following algebraic inequality?

 3  x < 5-3\ \le\ x\ <\ 5  

-3 < x || x < 5 

-3 <= x || x < 5

-3 < x && x < 5 

-3 < = x && x < 5 

7.

MULTIPLE CHOICE QUESTION

5 mins • 1 pt

Consider the following code assuming the variables have been properly defined.

String mystery_word = new String ("Comp Sci ");

System.out.println ("Enter a word ");

String word = reader.nextLine();

// compare the word to the mystery word

if (*** line of code goes here ****)

System.out.println ( "your word matches");

else

System.out.println ("The words do not match");

What is the proper code to compare the two words?

! (word.equals(mystery_word))

! ( word == mystery_word)

(word.equals(mystery_word))

(word == mystery_word)

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?