Search Header Logo

CS 2 Unit 1 Review

Authored by Jon Kern

Computers

9th - 12th Grade

Used 5+ times

CS 2 Unit 1 Review
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

14 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following is not a primitive type?

int

double

String

boolean

char

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the value of x after this code runs?

int x = 5;

x = 10;

x = 4;

5

10

4

true

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What is the value of myInteger after this line of code is executed?

int myInteger = (int) 5.6;

6

5.6

5

9

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What output will be produced by

System.out.println("Hello");

System.out.println("Karel");

Hello Karel

HelloKarel

Hello

Karel

error

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will the following code print?

int n = 5;

n ++;

n ++;

n += n;

System.out.println(n);

12

40

14

18

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following would equal 2?

I.

int x = 0;

x ++;

x += x;

II.

int y = 4;

y ++;

y /= 2;

III.

int z = 4;

z += 2;

z /= 2;

I only

II only

III only

I and II only

I, II, and III

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

The following code is intended to print 8.

int x = 23;

double y = 3;

System.out.println((int)(x / y));

What is printed and why?

7 because the values of x and y are integers so 23 / 3 evaluated to 7

7 because x / y calculates to 7.66 then the cast to an int results in the value getting truncated to 7

8 because the values of x and y are integers so 23 / 3 evaluated to 8

8 because x / y calculates to 7.66 then the cast to an int results in the value getting rounded up to 8

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?