AP CSA Unit 1&2 Test

AP CSA Unit 1&2 Test

Assessment

Assessment

Created by

Ashmit Grover

Computers

8th Grade - Professional Development

12 plays

Hard

Student preview

quiz-placeholder

25 questions

Show answers

1.

Multiple Choice

1 min

1 pt

Consider the following code segment.


System.out.println("W");

System.out.println("X");

System.out.print("Y");

System.out.print("Z");


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

WXYZ

W

XYZ

WX

YZ

W

X

YZ

W

X

Y

Z

2.

Multiple Choice

1 min

1 pt

Consider the following code segment.


int x = 10;

int y = 20;

/* missing code */

System.out.print(top / bottom);


Which of the following replacements for /* missing code */ will cause an ArithmeticException to occur?


I. int top = x - y;int bottom = y - x;

II.int top = 2 * x;int bottom = y - top;

III. int top = x + y;int bottom = 2 * top;

I. only

II. only

III. only

I. and II.

II. and III.

3.

Multiple Choice

1 min

1 pt

Consider the following code segment.


String str = "AP";

str += "CS " + 1 + 2;

System.out.println(str);


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

CS AP12

AP CS3

CSAP 12

APCS 12

APCS 3

4.

Multiple Choice

1 min

1 pt

Consider the following code segment.


String one = "ABC123";

String two = "C";

String three = "3";

System.out.println(one.indexOf(two));

System.out.println(one.indexOf(three));

System.out.println(two.indexOf(one));


What is printed when the code segment is executed?

2

5

-1

2

5

2

2

6

-1

3

6

-1

-1

-1

2

5.

Multiple Choice

1 min

1 pt

Consider the following method.


public double calculate(double x)

{

return x + 1.5;

}


The following code segment calls the method calculate in the same class.


Double d1 = new Double(7.5);

System.out.println(calculate(d1));


What, if anything, is printed when the code segment is executed?

8.0

8.5

9

9.0

Nothing is printed because the code does not compile. The actual parameter d1 passed to calculate is a Double, but the formal parameter x is a double.

Explore all questions with a free account

or continue with
Microsoft
Apple
Others
By signing up, you agree to our Terms of Service & Privacy Policy
Already have an account?

Find a similar activity

Create activity tailored to your needs using

Quizizz AI
2nd-year set 2

20 questions

2nd-year set 2

assessment

University

Arrays and Strings Revision

20 questions

Arrays and Strings Revision

assessment

9th - 12th Grade

AP CSA Unit 1 Intro

20 questions

AP CSA Unit 1 Intro

assessment

12th Grade

AP CSA unit 1 - 4 TEST

23 questions

AP CSA unit 1 - 4 TEST

assessment

9th - 12th Grade

AP CSA Unit Review

25 questions

AP CSA Unit Review

assessment

11th - 12th Grade

AP  Computer Science Unit 1 Review

28 questions

AP Computer Science Unit 1 Review

assessment

11th Grade

AP_CSA Ch1

20 questions

AP_CSA Ch1

assessment

9th - 12th Grade

AP CS A CH 1 Review

27 questions

AP CS A CH 1 Review

assessment

10th - 12th Grade