Given the code fragment:
List
empDetails.stream()
.filter(s-> s.contains(''r''))
.sorted()
.forEach(System.out::println); //line n1
What is the result?
Given:
class Vehicle implements Comparable
int vno;
String name;
public Vehicle (int vno, String name) {
this.vno = vno,;
this.name = name;
}
public String toString () {
return vno + '':'' + name;
}
public int compareTo(Vehicle o) {
return this.name.compareTo(o.name);
}
and this code fragment:
Set
vehicles.add(new Vehicle (10123, ''Ford''));
vehicles.add(new Vehicle (10124, ''BMW''));
System.out.println(vehicles);
What is the result?
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;
}
public String getCourse() {return course;}
public String getName() {return name;}
public String getCity() {return city;}
and the code fragment:
List
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(res));
What is the result?
Given the code fragments:
class Employee {
Optional
address;Employee (Optional
address) {this.address = address;
}
public Optional
getAddress() { return address; }}
class Address {
String city = ''New York'';
public String getCity { return city: }
public String toString() {
return city;
}
}
and
Address address = new Address;
Optional
addrs1 = Optional.ofNullable (address);Employee e1 = new Employee (addrs1);
String eAddress = (addrs1.isPresent()) ? addrs1.get().getCity() : ''City Not
available'';
System.out.println(eAddress);
What is the result?
Given the code fragment:
public void recDelete (String dirName) throws IOException {
File [ ] listOfFiles = new File (dirName) .listFiles();
if (listOfFiles ! = null && listOfFiles.length >0) {
for (File aFile : listOfFiles) {
if (!aFile.isDirectory ()) {
if (aFile.getName ().endsWith (''.class''))
aFile.delete ();
}
}
}
}
Assume that Projects contains subdirectories that contain .class files and is passed as an argument to the recDelete () method when it is invoked.
What is the result?
Submit Cancel