Question 1

Given the code fragment:

What is the result?
  • Question 2

    Given the code fragment: List colors = new ArrayList(); colors.add("green");
    colors.add("red");
    colors.add("blue");
    colors.add("yellow");
    colors.remove(2);
    colors.add(3,"cyan");
    System.out.print(colors);
    What is the result?
  • Question 3

    Given:

    What three modifications, made independently, made to class greet, enable the code to compile and run?
  • Question 4

    Given the code fragment:

    Which modification enables the code to print 54321?
  • Question 5

    Given the following code for the classes MyException and Test:

    What is the result?