Question 6

Given:
java
var counter = 0;
do {
System.out.print(counter + " ");
} while (++counter < 3);
What is printed?
  • Question 7

    Which of the following can be the body of a lambda expression?
  • Question 8

    Given:
    java
    public static void main(String[] args) {
    try {
    throw new IOException();
    } catch (IOException e) {
    throw new RuntimeException();
    } finally {
    throw new ArithmeticException();
    }
    }
    What is the output?
  • Question 9

    Given:
    java
    public class SpecialAddition extends Addition implements Special {
    public static void main(String[] args) {
    System.out.println(new SpecialAddition().add());
    }
    int add() {
    return --foo + bar--;
    }
    }
    class Addition {
    int foo = 1;
    }
    interface Special {
    int bar = 1;
    }
    What is printed?
  • Question 10

    Given:
    java
    ExecutorService service = Executors.newFixedThreadPool(2);
    Runnable task = () -> System.out.println("Task is complete");
    service.submit(task);
    service.shutdown();
    service.submit(task);
    What happens when executing the given code fragment?