Question 36

Given: What is the result?
  • Question 37

    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?
    ur :: va
  • Question 38

    Given the code fragments:
    class Employee {
    Optional<Address> address;
    Employee (Optional<Address> address) {
    this.address = address;
    }
    public Optional<Address> getAddress() { return address; }
    }
    class Address {
    String city = "New York";
    public String getCity { return city: }
    public String toString() {
    return city;
    }
    }
    and
    Address address = null;
    Optional<Address> addrs1 = Optional.ofNullable (address);
    Employee e1 = new Employee (addrs1);
    String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : "City Not
    available";
    What is the result?
  • Question 39

    Given:
    1. abstract class Shape {
    2. Shape ( ) { System.out.println (“Shape”); }
    3. protected void area ( ) { System.out.println (“Shape”); }
    4. }
    5.
    6. class Square extends Shape {
    7. int side;
    8. Square int side {
    9. /* insert code here */
    10. this.side = side;
    11. }
    12. public void area ( ) { System.out.println (“Square”); }
    13. }
    14. class Rectangle extends Square {
    15. int len, br;
    16. Rectangle (int x, int y) {
    17. /* insert code here */
    18. len = x, br = y;
    19. }
    20. void area ( ) { System.out.println (“Rectangle”); }
    21. }
    Which two modifications enable the code to compile?
  • Question 40

    What is true about the java.sql.Statement interface?