Loading questions...
Updated
Given the definition of the Vehicle class:
Class Vehicle {
int distance;
Vehicle (int x) {
this distance = x;
}
public void increSpeed(int time) {
int timeTravel = time; //line n1
//line n3
class Car {
int value = 0;
public void speed () {
value = distance /timeTravel; //line n2
System.out.println ("Velocity with new speed"+value+"kmph");
}
}
speed(); //line n3
}
}
and this code fragment:
Vehicle v = new Vehicle (100);
v.increSpeed(60);
What is the result?
Given the code fragment:
Path source = Paths.get ("/data/december/log.txt");
Path destination = Paths.get("/data");
Files.copy (source, destination);
/data/december/log.txt is accessible and contains:
and assuming that the file
10-Dec-2014 Executed successfully
What is the result?
log.txt is created in the /data directory and the content of the /data/december/log.txt file is copied to it.
Given the content of Operator.java, EngineOperator.java, and Engine.java files:
Given the code fragment:
Given the code fragment:
Given:
Given the code fragment:
Given the code fragments:
Given the code fragment:
Given the code fragment:
Given the code fragment:
Given the code fragment:
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?
Vehicle class public.
Given the code fragment:
Stream<List<String>> iStr= Stream.of (
Arrays.asList ("1", "John"),
Arrays.asList ("2", null));
Stream<<String> nInSt = iStr.flatMapToInt ((x) -> x.stream ()); nInSt.forEach (System.out :: print);
What is the result?
Given:
public class Emp {
String fName;
String lName;
public Emp (String fn, String ln) {
fName = fn;
lName = ln;
}
public String getfName() { return fName; }
public String getlName() { return lName; }
}
and the code fragment:
List<Emp> emp = Arrays.asList (
new Emp ("John", "Smith"),
new Emp ("Peter", "Sam"),
new Emp ("Thomas", "Wale"));
emp.stream()
//line n1
.collect(Collectors.toList());
fName and then ascending order of lName?
Which code fragment, when inserted at line n1, sorts the employees list in descending order of
Given:
Given:
Given the code fragment:
Given the code fragments:
Which two are elements of a singleton class? (Choose two.)
Given the code fragment:
Given:
Given:
IntStream stream = IntStream.of (1,2,3);
IntFunction<Integer> inFu= x -> y -> x*y; //line n1
IntStream newStream = stream.map(inFu.apply(10)); //line n2 newStream.forEach(System.output::print);
Which modification enables the code fragment to compile?
line n1 with:
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);
v.increSpeed(60);
What is the result?
Velocity with new speed -
and the code fragment:
What is the result?
Which code fragment, when inserted at line n1, ensures false is printed?
What is the result?
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?
What is the result?
and
What is the result?
Which code fragment, when inserted at line n1, enables the code to print /First.txt?
Assume that:
The required database driver is configured in the classpath.
The appropriate database is accessible with the dbURL, userName, and passWord exists
The Employee table has a column ID of type integer and the SQL query matches one record.
What is the result?
What is the result?
and the code fragment?
What is the result?
What is the result?
and
Which interface from the java.util.function package should you use to refactor the class Txt?
and the command: java Product 0
What is the result?
Assume that the value of now is 6:30 in the morning.
What is the result?
and
What is the result?
What is the result?
and the code fragment:
Which two code fragments, when inserted at line n1 independently, enable the code to print TruckCarBike?