Question 21

Given the code fragments:

and

What is the result?
  • Question 22

    Given:
    public class Foo<K, V> {
    private K key;
    private V value;
    public Foo (K key, V value) (this.key = key; this value = value;)
    public static <T> Foo<T, T> twice (T value) (return new Foo<T, T> (value, value); )
    public K getKey () (return key;)
    public V getValue () (return value;)
    }
    Which option fails?
  • Question 23

    Assume customers.txtis accessible and contains multiple lines.
    Which code fragment prints the contents of the customers.txtfile?
    Stream<String> stream = Files.find (Paths.get ("customers.txt"));
  • Question 24

    Given the code fragment:

    Assume that:
    The required database driver is configured in the classpath.
    The appropriate database is accessible with the dbURL, userName, and passWordexists The Employeetable has a column ID of type integer and the SQL query matches one record.
    What is the result?
  • Question 25

    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 */
    1 0. this.side = side;
    1 1. }
    1 2. public void area ( ) { System.out.println ("Square"); }
    1 3. }
    1 4. class Rectangle extends Square {
    1 5. int len, br;
    1 6. Rectangle (int x, int y) {
    1 7. /* insert code here */
    1 8. len = x, br = y;
    1 9. }
    2 0. void area ( ) { System.out.println ("Rectangle"); }
    2 1. }
    Which two modifications enable the code to compile?