Guaranteed Accomplishment with Newest Jan-2022 FREE Oracle 1z0-809
Use Valid New Free 1z0-809 Exam Dumps & Answers
NEW QUESTION 115
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?
- A. A compilation error occurs at line n1.
- B. A compilation error occurs at line n2.
- C. John Jim
- D. Sam John Jim
Answer: C
NEW QUESTION 116
Given the code fragment:
List<String> str = Arrays.asList ("my", "pen", "is", "your', "pen");
Predicate<String> test = s -> {
int i = 0;
boolean result = s.contains ("pen");
System.out.print(i++) + ":");
return result;
};
str.stream()
. filter(test)
. findFirst()
. ifPresent(System.out ::print);
What is the result?
- A. 0 : 1 : 2 : 3 : 4 :
- B. 0 : 0 : pen
- C. 0 : 0 : 0 : 0 : 0 : pen
- D. 0 : 1 : pen
- E. A compilation error occurs.
Answer: E
NEW QUESTION 117
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?
- A. 0
- B. 1
- C. 2
- D. An Exception is thrown at runtime.
Answer: D
NEW QUESTION 118
Assume customers.txt is accessible and contains multiple lines.
Which code fragment prints the contents of the customers.txt file?
- A. Stream<String> lines = Files.lines (Paths.get ("customers.txt"));lines.forEach( c) -> System.out.println(c));
- B. Stream<String> stream = Files.find (Paths.get ("customers.txt"));stream.forEach((String c) -> System.out.println(c));
- C. Stream<Path> stream = Files.find (Paths.get ("customers.txt"));stream.forEach( c) -> System.out.println(c));
- D. Stream<Path> stream = Files.list (Paths.get ("customers.txt"));stream.forEach( c) -> System.out.println(c));
Answer: A
NEW QUESTION 119
Given the code fragment:
public class FileThread implements Runnable {
String fName;
public FileThread(String fName) { this.fName = fName; }
public void run () System.out.println(fName);}
public static void main (String[] args) throws IOException, InterruptedException {
ExecutorService executor = Executors.newCachedThreadPool();
Stream<Path> listOfFiles = Files.walk(Paths.get("Java Projects"));
listOfFiles.forEach(line -> {
executor.execute(new FileThread(line.getFileName().toString())); //
line n1
});
executor.shutdown();
executor.awaitTermination(5, TimeUnit.DAYS);//
line n2
}
}
The Java Projects directory exists and contains a list of files.
What is the result?
- A. A compilation error occurs at line n1.
- B. The program prints files names concurrently.
- C. The program prints files names sequentially.
- D. The program throws a runtime exception at line n2.
Answer: B
NEW QUESTION 120
Given the code fragment:
BiFunction<Integer, Double, Integer> val = (t1, t2) -> t1 + t2; //line n1
System.out.println(val.apply(10, 10.5));
What is the result?
- A. A compilation error occurs at line n1.
- B. A compilation error occurs at line n2.
- C. 20.5
- D. 0
Answer: A
NEW QUESTION 121
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());
Which code fragment, when inserted at line n1, sorts the employees list in descending order of fNameand then ascending order of lName?
.sorted (Comparator.comparing(Emp::getfName).reserved().thenComparing
- A. (Emp::getlName).reserved
- B. .map(Emp::getfName).sorted(Comparator.reserveOrder().map
- C. .map(Emp::getfName).sorted(Comparator.reserveOrder())
- D. (Emp::getlName))
.sorted (Comparator.comparing(Emp::getfName).thenComparing(Emp::getlName))
Answer: D
NEW QUESTION 122
Given:
public class Test<T> {
private T t;
public T get () {
return t;
}
public void set (T t) {
this.t = t;
}
public static void main (String args [ ] ) {
Test<String> type = new Test<>();
Test type 1 = new Test ();//line n1
type.set("Java");
type1.set(100);//line n2
System.out.print(type.get() + " " + type1.get());
}
}
What is the result?
- A. A compilation error occurs. To rectify it, replace line n1 with:
Test<Integer> type1 = new Test<>(); - B. Java 100
- C. A compilation error occurs. To rectify it, replace line n2 with:
type1.set (Integer(100)); - D. java.lang.string@<hashcode
Answer: A
NEW QUESTION 123
Given the content:
and the code fragment:
What is the result?
- A. username = Entrez le nom d'utilisateur
password = Entrez le mot de passe - B. A compilation error occurs.
- C. The program prints nothing.
- D. username = Enter User Name
password = Enter Password
Answer: A
NEW QUESTION 124
Which statement is true about java.util.stream.Stream?
- A. A parallel stream is always faster than an equivalent sequential stream.
- B. The execution mode of streams can be changed during processing.
- C. Streams are intended to modify the source data.
- D. A stream cannot be consumed more than once.
Answer: D
NEW QUESTION 125
Which statement is true about java.time.Duration?
- A. It tracks time zones.
- B. It preserves daylight saving time.
- C. It defines date-based values.
- D. It defines time-based values.
Answer: D
Explanation:
Reference: http://tutorials.jenkov.com/java-date-time/duration.html#accessing-the-time-ofa-duration
NEW QUESTION 126
Given the code fragment:
Stream<Path> files = Files.walk(Paths.get(System.getProperty("user.home")));
files.forEach (fName -> {//line n1
try {
Path aPath = fName.toAbsolutePath();//line n2
System.out.println(fName + ":"
+ Files.readAttributes(aPath, Basic.File.Attributes.class).creationTime
());
} catch (IOException ex) {
ex.printStackTrace();
});
What is the result?
- A. A compilation error occurs at line n1.
- B. A compilation error occurs at line n2.
- C. The files in the home directory are listed along with their attributes.
- D. All files and directories under the home directory are listed along with their attributes.
Answer: D
NEW QUESTION 127
Given the code fragment:
What is the result?
- A. Match 2
- B. A nullPointerException is thrown at runtime.
- C. Match 1
- D. No Match
Answer: A
NEW QUESTION 128
Given:
public class Counter {
public static void main (String[ ] args) {
int a = 10;
int b = -1;
assert (b >=1) : "Invalid Denominator";
int = a / b;
System.out.println (c);
}
}
What is the result of running the code with the -ea option?
- A. 0
- B. A compilation error occurs.
- C. An AssertionError is thrown.
- D. 1
Answer: C
NEW QUESTION 129
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?
- A. A compilation error occurs at line n1.
- B. A compilation error occurs at line n2.
- C. John Jim
- D. Sam John Jim
Answer: C
NEW QUESTION 130
Given the code format:
Which code fragment must be inserted at line 6 to enable the code to compile?
- A. Return DBConfiguration;
- B. Return new DBConfiguration;
- C. DBConfiguration f;
return f; - D. Retutn 0;
Answer: B
NEW QUESTION 131
Given:
What is the result?
- A. 0 0 30 40
- B. Compilation fails.
- C. An exception is thrown at runtime.
- D. 10 20 30 40
Answer: A
NEW QUESTION 132
Given:
public class ScopeTest {
int j, int k;
public static void main(String[] args) {
ew ScopeTest().doStuff(); }
void doStuff() {
nt x = 5;
oStuff2();
System.out.println("x");
}
void doStuff2() {
nt y = 7;
ystem.out.println("y");
or (int z = 0; z < 5; z++) {
ystem.out.println("z");
ystem.out.println("y");
}
Which two items are fields?
- A. x
- B. y
- C. z
- D. k
- E. j
Answer: D,E
NEW QUESTION 133
Given:
class Vehicle {
int vno;
String name;
public Vehicle (int vno, String name) {
this.vno = vno,;
this.name = name;
}
public String toString () {
return vno + ":" + name;
}
}
and this code fragment:
Set<Vehicle> vehicles = new TreeSet <> ();
vehicles.add(new Vehicle (10123, "Ford"));
vehicles.add(new Vehicle (10124, "BMW"));
System.out.println(vehicles);
What is the result?
- A. A compilation error occurs.
- B. 10124 BMW10123 Ford
- C. A ClassCastException is thrown at run time.
- D. 10123 Ford10124 BMW
Answer: C
NEW QUESTION 134
Given:
Which option fails?
- A. Foo<Object, Object> percentage = new Foo<String, Integer>("Steve", 100);
- B. Foo<String, String> grade = new Foo <> ("John", "A");
- C. Foo<String, String> pair = Foo.<String>twice ("Hello World!");
- D. Foo<String, Integer> mark = new Foo<String, Integer> ("Steve", 100);
Answer: A
NEW QUESTION 135
Given:
What is the result?
- A. 10 Hello Hello 11
- B. 100 Hello Hello 121
- C. 10 Hello Hello 121
- D. 10 Hello 11
- E. 100 Hello 121
Answer: A
NEW QUESTION 136
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() <= 60;//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?
- A. A compilation error occurs at line n1.
- B. A compilation error occurs at line n2.
- C. John Jim
- D. Sam John Jim
Answer: A
NEW QUESTION 137
......
1z0-809 Braindumps PDF, Oracle 1z0-809 Exam Cram: https://measureup.preppdf.com/Oracle/1z0-809-prepaway-exam-dumps.html