Search Header Logo

Unit 4 practice question set 3

Authored by Caleb Kim

Computers

9th - 12th Grade

Used 1+ times

Unit 4 practice question set 3
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

15 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

int x = 8;
int y = 7;

boolean b = x<y || x==8;

System.out.println(b);

True

False

2.

FILL IN THE BLANK QUESTION

1 min • 1 pt

What is the output of the following code?

int x = 5;
int y = 3;

if(x-- < 5 && y-->2)
System.out.print("A");
if(x==4 && ++y>1)
System.out.print("B");
if(x==y)
System.out.print("C");

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

int x=1;

if(x<3)
System.out.println("small");
if(x<6)
System.out.println("medium");
if (x<10)
System.out.println("large");

large

small
medium
large


medium

small

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

When does an || statement short-circuit?

When the left operand is false


When the right operand is true


When the right operand is false


When the left operand is true

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the output of the following code?

int x = 8;
int y = 7;

boolean b = x<y && x==8;

System.out.println(b);

True

False

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code?

 

int a = 5;
if (a > 0) {
    if (a < 10) {
        System.out.println("Small number");
    } else {
        System.out.println("Large number");
    }
}

Compilation error


Small number

Large number


No output

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the result of the following code when temperature is set to 75?

int temperature = 75;
if (temperature < 60) {
    System.out.println("Cold");
} else if (temperature >= 60 && temperature < 80) {
    System.out.println("Warm");
} else {
    System.out.println("Hot");
}

no output

hot

warm

cold

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?