Weekend Sale - Limited Time 70% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sntaclus

Given:

class Student {

String course, name, city;

public Student (String name, String course, String city) {

this.course = course; this.name = name; this.city = city;

}

public String toString() {

return course + “:” + name + “:” + city;

}

and the code fragment:

List stds = Arrays.asList(

new Student (“Jessy”, “Java ME”, “Chicago”),

new Student (“Helen”, “Java EE”, “Houston”),

new Student (“Mark”, “Java ME”, “Chicago”));

stds.stream()

.collect(Collectors.groupingBy(Student::getCourse))

.forEach(src, res) -> System.out.println(scr));

What is the result?

A.

[Java EE: Helen:Houston][Java ME: Jessy:Chicago, Java ME: Mark:Chicago]

B.

Java EEJava ME

C.

[Java ME: Jessy:Chicago, Java ME: Mark:Chicago][Java EE: Helen:Houston]

D.

A compilation error occurs.

Given:

public class Customer {

private String fName;

private String lName;

private static int count;

public customer (String first, String last) {fName = first, lName = last;

++count;}

static { count = 0; }

public static int getCount() {return count; }

}

public class App {

public static void main (String [] args) {

Customer c1 = new Customer(“Larry”, “Smith”);

Customer c2 = new Customer(“Pedro”, “Gonzales”);

Customer c3 = new Customer(“Penny”, “Jones”);

Customer c4 = new Customer(“Lars”, “Svenson”);

c4 = null;

c3 = c2;

System.out.println (Customer.getCount());

}

}

What is the result?

A.

0

B.

2

C.

3

D.

4

E.

5

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?

A.

An exception is thrown at runtime.

B.

Compilation fails.

C.

The code prints Error.

D.

The code prints information about Item 110.

Given:

What is the result?

A.

Hi Interface-2

B.

A compilation error occurs.

C.

Hi Interface-1

D.

Hi MyClass

Given the definition of the Vehicle class:

class Vehicle {

String name;

void setName (String name) {

this.name = name;

}

String getName() {

return name;

}

}

Which action encapsulates the Vehicle class?

A.

Make the Vehicle class public.

B.

Make the name variable public.

C.

Make the setName method public.

D.

Make the name variable private.

E.

Make the setName method private.

F.

Make the getName method private.

Given:

Your design requires that:

    fuelLevel of Engine must be greater than zero when the start() method is invoked.

    The code must terminate if fuelLevel of Engine is less than or equal to zero.

Which code fragment should be added at line n1 to express this invariant condition?

A.

assert (fuelLevel) : “Terminating…”;

B.

assert (fuelLevel > 0) : System.out.println (“Impossible fuel”);

C.

assert fuelLevel < 0: System.exit(0);

D.

assert fuelLevel > 0: “Impossible fuel” ;

Given the code fragment:

Which modification enables the code to print Price 5 New Price 4?

A.

Replace line n2 with .map (n -> System.out.println (“New Price” + n –1)) and remove line n3

B.

Replace line n2 with .mapToInt (n -> n – 1);

C.

Replace line n1 with .forEach (e -> System.out.print (“Price” + e))

D.

Replace line n3 with .forEach (n -> System.out.println (“New Price” + n));

Given the code fragment:

What is the result?

A.

A compilation error occurs at line n1.

B.

courseJava

C.

Javacourse

D.

A compilation error occurs at line n2.

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.getInt(“Id”));

16.System.out.println(“Description:“ + rs.getString(“Descrip”));

17.System.out.println(“Price:“ + rs.getDouble(“Price”));

18. System.out.println(Quantity:“ + rs.getInt(“Quantity”));

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?

A.

An exception is thrown at runtime.

B.

Compilation fails.

C.

The code prints Error.

D.

The code prints information about Item 110.

Assume customers.txt is accessible and contains multiple lines.

Which code fragment prints the contents of the customers.txt file?

A.

Stream stream = Files.find (Paths.get (“customers.txt”));stream.forEach((String c) -> System.out.println(c));

B.

Stream stream = Files.find (Paths.get (“customers.txt”));stream.forEach( c) -> System.out.println(c));

C.

Stream stream = Files.list (Paths.get (“customers.txt”));stream.forEach( c) -> System.out.println(c));

D.

Stream lines = Files.lines (Paths.get (“customers.txt”));lines.forEach( c) -> System.out.println(c));