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?
Given the code fragment:
List
DoubleFunction funD = d –> d + 100.0;
doubles.stream (). forEach (funD); // line n1
doubles.stream(). forEach(e –> System.out.println(e)); // line n2
What is the result?
Given:
public class Counter {
public static void main (String[ ] args) {
int a = 10;
int b = -1;
assert (b >=1) : “Invalid Denominatorâ€;
int Ñ = a / b;
System.out.println (c);
}
}
What is the result of running the code with the –ea option?
Given:
IntStream stream = IntStream.of (1,2,3);
IntFunction
IntStream newStream = stream.map(inFu.apply(10));//line n2
newStream.forEach(System.out::print);
Which modification enables the code fragment to compile?
Given the code fragments:
class ThreadRunner implements Runnable {
public void run () { System.out.print (“Runnableâ€) ; }
}
class ThreadCaller implements Callable {
Public String call () throws Exception {return “Callableâ€; )
}
and
ExecutorService es = Executors.newCachedThreadPool ();
Runnable r1 = new ThreadRunner ();
Callable c1 = new ThreadCaller ();
// line n1
es.shutdown();
Which code fragment can be inserted at line n1 to start r1 and c1 threads?
Given:
Item table
• ID, INTEGER: PK
• DESCRIP, VARCHAR(100)
• PRICE, REAL
• QUANTITY< INTEGER
And given the code fragment:
9. try {
10.Connection conn = DriveManager.getConnection(dbURL, username, password);
11. String query = “Select * FROM Item WHERE ID = 110â€;
12. Statement stmt = conn.createStatement();
13. ResultSet rs = stmt.executeQuery(query);
14.while(rs.next()) {
15.System.out.println(“ID:“ + rs.getString(1));
16.System.out.println(“Description:“ + rs.getString(2));
17.System.out.println(“Price:“ + rs.getString(3));
18. System.out.println(Quantity:“ + rs.getString(4));
19.}
20. } catch (SQLException se) {
21. System.out.println(“Errorâ€);
22. }
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists.
The SQL query is valid.
What is the result?
Given the content:
and given the code fragment:
Which two code fragments, when inserted at line 1 independently, enable the code to print “Wie geht’s?â€