MultipleChoice
Given:
class FuelNotAvailException extends Exception { }
class Vehicle {
void ride() throws FuelNotAvailException {//line n1
System.out.println(''Happy Journey!'');
}
}
class SolarVehicle extends Vehicle {
public void ride () throws FuelNotAvailException {//line n2
super ride ();
}
}
and the code fragment:
public static void main (String[] args) throws Exception {
Vehicle v = new SolarVehicle ();
v.ride();
}
Which modification enables the code fragment to print Happy Journey!?
OptionsMultipleChoice
Given that these files exist and are accessible:
/sports/info.txt
/sports/cricket/players.txt
/sports/cricket/data/ODI.txt
and given the code fragment:
int maxDepth =2;
Stream<Path> paths = Files.find(Paths.get(''/sports''),
maxDepth,
(p, a) -> p.getFileName().toString().endsWith (''txt''),
FileVisitOption.FOLLOW_LINKS);
Long fCount = paths.count();
System.out.println(fCount);
Assuming that there are NO soft-link/symbolic links to any of the files in the directory structure, what is the result?
OptionsMultipleChoice
Given:
What change should you make to guarantee a single order of execution (printed values 1 -100 in order)?
OptionsMultipleChoice
Given the structure of the Student table:
Student (id INTEGER, name VARCHAR)
Given the records from the STUDENT table:
Given the code fragment:
Assume that:
What is the result?
OptionsMultipleChoice
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?
OptionsMultipleChoice
Given:
IntStream stream = IntStream.of (1,2,3);
IntFunction
IntStream newStream = stream.map(inFu.apply(10)); //line n2
newStream.forEach(System.output::print);
Which modification enables the code fragment to compile?
OptionsMultipleChoice
Given the definition of the Country class:
public class country {
public enum Continent {ASIA, EUROPE}
String name;
Continent region;
public Country (String na, Continent reg) {
name = na, region = reg;
}
public String getName () {return name;}
public Continent getRegion () {return region;}
}
and the code fragment:
List
new Country (''Japan'', Country.Continent.ASIA),
new Country (''Italy'', Country.Continent.EUROPE),
new Country (''Germany'', Country.Continent.EUROPE));
Map
.collect(Collectors.groupingBy (Country ::getRegion,
Collectors.mapping(Country::getName, Collectors.toList()))));
System.out.println(regionNames);
OptionsMultipleChoice
Given the structure of the Student table:
Student (id INTEGER, name VARCHAR)
Given the records from the STUDENT table:
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 passWord exists.
What is the result?
OptionsMultipleChoice
Given the code fragment:
UnaryOperator<Integer> uo1 = s -> s*2;line n1
List<Double> loanValues = Arrays.asList(1000.0, 2000.0);
loanValues.stream()
.filter(lv -> lv >= 1500)
.map(lv -> uo1.apply(lv))
.forEach(s -> System.out.print(s + '' ''));
What is the result?
OptionsMultipleChoice
Given the definition of the Emp class:
public class Emp
private String eName;
private Integer eAge;
Emp(String eN, Integer eA) {
this.eName = eN;
this.eAge = eA;
}
public Integer getEAge () {return eAge;}
public String getEName () {return eName;}
}
and code fragment:
List<Emp>li = Arrays.asList(new Emp(''Sam'', 20), New Emp(''John'', 60), New Emp(''Jim'', 51));
Predicate<Emp> agVal = s -> s.getEAge() > 50;//line n1
li = li.stream().filter(agVal).collect(Collectors.toList());
Stream<String> names = li.stream()map.(Emp::getEName);//line n2
names.forEach(n -> System.out.print(n + '' ''));
What is the result?
Options