Given the definition of the Vehicle class:
Class Vehhicle {
int distance; //line n1
Vehicle (int x) {
this distance = x;
}
public void increSpeed(int time) { //line n2
int timeTravel = time; //line n3
class Car {
int value = 0;
public void speed () {
value = distance /timeTravel;
System.out.println ("Velocity with new speed"+value+"kmph");
}
}
new Car().speed();
}
}
and this code fragment:
Vehicle v = new Vehicle (100);
A. increSpeed(60); What is the result?
B. Velocity with new speed
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
E. A compilation error occurs at line n3.
Given the code fragment:
List
"200, Mary, AdminServices",
"101, Peter, HR");
empDetails.stream()
.filter(s-> s.contains("1"))
.sorted()
.forEach(System.out::println); //line n1
What is the result?
A. 100, Robin, HR 101, Peter, HR
B. A compilation error occurs at line n1.
C. 100, Robin, HR 101, Peter, HR 200, Mary, AdminServices
D. 100, Robin, HR 200, Mary, AdminServices 101, Peter, HR
Given:
public final class IceCream {
public void prepare() {}
}
public class Cake {
public final void bake(int min, int temp) {}
public void mix() {}
}
public class Shop {
private Cake c = new Cake ();
private final double discount = 0.25;
public void makeReady () { c.bake(10, 120); }
}
public class Bread extends Cake {
public void bake(int minutes, int temperature) {}
public void addToppings() {}
}
Which statement is true?
A. A compilation error occurs in IceCream.
B. A compilation error occurs in Cake.
C. A compilation error occurs in Shop.
D. A compilation error occurs in Bread
E. All classes compile successfully.
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.
Given the code fragment:
LocalDate valentinesDay =LocalDate.of(2015, Month.FEBRUARY, 14);
LocalDate nextYear = valentinesDay.plusYears(1);
nextYear.plusDays(15); //line n1
System.out.println(nextYear);
What is the result?
A. 2016-02-14
B. A DateTimeException is thrown.
C. 2016-02-29
D. A compilation error occurs at line n1.
Given: and the code fragment:
What is the result?
A. A compilation error occurs at line n2.
B. A compilation error occurs because the try block doesn't have a catch or finally block.
C. A compilation error occurs at line n1.
D. The program compiles successfully.
and the code fragment?
What is the result?
A. $15.00
B. 15 $
C. USD 15.00
D. USD $15
Given:
Which two interfaces can you use to create lambda expressions? (Choose two.)
A. T
B. R C. P
D. S
E. Q
F. U
Given the code fragments: and
Which two modifications enable to sort the elements of the emps list? (Choose two.)
A. Replace line n1 with class Person extends Comparator
B. At line n2 insert public int compareTo (Person p) { return this.name.compareTo (p.name); }
C. Replace line n1 with class Person implements Comparable
D. At line n2 insert public int compare (Person p1, Person p2) { return p1.name.compareTo (p2.name); }
E. At line n2 insert: public int compareTo (Person p, Person p2) { return p1.name.compareTo (p2.name); }
F. Replace line n1 with class Person implements Comparator
Given the code fragment:
What is the result?
A. ACBD // in random order ABCD
B. ABCD // in random order ABCD // in random order
C. ABCD // in random order BCAD
D. A compile time error occurs.