Computers

8th -

Professional Development

Image

AP CSA Unit 1&2 Test

12
plays

25 questions

Show Answers
See Preview
  • 1. Multiple Choice
    1 minute
    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 minute
    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 minute
    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

  • Answer choices
    Tags
    Answer choices
    Tags

    Explore all questions with a free account

    Already have an account?