Question 101

Given the code fragment:

What is the result?
  • Question 102

    Given that course.txt is accessible and contains:
    Course : : Java
    and given the code fragment:
    public static void main (String[ ] args) {
    int i;
    char c;
    try (FileInputStream fis = new FileInputStream ("course.txt");
    InputStreamReader isr = new InputStreamReader(fis);) {
    while (isr.ready()) { //line n1
    isr.skip(2);
    i = isr.read ();
    c = (char) i;
    System.out.print(c);
    }
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    What is the result?
  • Question 103

    Given:
    class Bird {
    public void fly () { System.out.print("Can fly"); }
    }
    class Penguin extends Bird {
    public void fly () { System.out.print("Cannot fly"); }
    }
    and the code fragment:
    class Birdie {
    public static void main (String [ ] args) {
    fly( ( ) -> new Bird ( ));
    fly (Penguin : : new);
    }
    /* line n1 */
    }
    Which code fragment, when inserted at line n1, enables the Birdie class to compile?
    static void fly (Consumer<Bird> bird) {
  • Question 104

    Which statement is true about Java byte code?
  • Question 105

    Given:

    And given the commands:

    What is the result?