Search Header Logo

Unit 3 Review

Authored by Karen Russo

Computers

9th - 12th Grade

Used 1+ times

Unit 3 Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

18 questions

Show all answers

1.

FILL IN THE BLANK QUESTION

1 min • 1 pt

If a = 15 and b = 12, what is the result of the following:

if (a ==10)

{ b = b + a;

a = 5; }

else if (a > 10)

{ a = a - b;

b = a * b; }

a = _______________ b = ____________

2.

FILL IN THE BLANK QUESTION

1 min • 1 pt

What will be the output for the following program segment?

int junk = 12;

if (junk > 5)

if (junk % 5 == 0)

System.out.println ("The value of junk is: " + junk);

else

System.out.println(("Junk is negative");

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Find the errors in the following if statement.

if x > 0 then System.out.println(x);

needs an == sign

No parentheses around x > 0

"then" is not used in java

No parentheses around x > 0 and "then" is not used in java

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Find the error in the following if statement.

if ( x = 1) { y ++;}

y ++ is not a valid statement

the curly brackets will cause a compile error

the condition should be (x == 1)

there is no else statement

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Find the error in the following if statement.

String word = new String("Hello");

String word2 = new String("Hello");

if (word == word2)

System.out.println("The words are the same");

else

System.out.println("The words are not the same");

it is missing curly brackets

you need to use .equals() instead of ==

you need to use = instead of ==

There is no error

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Find the error in the following if statements.

String word = new String ("Hello");

String word2 = new String("Hello");

if (word.equals(word2));

System.out.println("The words are the same");

else

System.out.println("The words are not the same");

use == instead of .equals()

there are no curly brackets

remove the ; at the end of the if condition

use = instead of .equals()

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the value of s if x = 5 and y = 2 after executing the following cod:

s = 0;

if (x > 0) { s++;}

if (y > 0) {s ++;}

s = 0

s = 1

s = 2

s = -2

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?