Your success in Oracle 1Z0-809 is our sole target and we develop all our 1Z0-809 braindumps in a way that facilitates the attainment of this target. Not only is our 1Z0-809 study material the best you can find, it is also the most detailed and the most updated. 1Z0-809 Practice Exams for Oracle Java 1Z0-809 are written to the highest standards of technical accuracy.
Q1. Given the code fragment:
String str = “Java is a programming language”; ToIntFunction<String> indexVal = str: : indexOf; //line n1 int x = indexVal.applyAsInt(“Java”);//line n2 System.out.println(x);
What is the result?
A. 0
B. 1
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Answer: A
Q2. 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<Country> couList = Arrays.asList (
new Country (“Japan”, Country.Continent.ASIA),
new Country (“Italy”, Country.Continent.EUROPE),
new Country (“Germany”, Country.Continent.EUROPE)); Map<Country.Continent, List<String>> regionNames = couList.stream () .collect(Collectors.groupingBy (Country ::getRegion, Collectors.mapping(Country::getName, Collectors.toList())))); System.out.println(regionNames);
What is the output?
A. {EUROPE = [Italy, Germany], ASIA = [Japan]}
B. {ASIA = [Japan], EUROPE = [Italy, Germany]}
C. {EUROPE = [Germany, Italy], ASIA = [Japan]}
D. {EUROPE = [Germany], EUROPE = [Italy], ASIA = [Japan]}
Answer: A
Q3. 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?
A. Replace line n1 with:
IntFunction<UnaryOperator> inFu = x -> y -> x*y;
B. Replace line n1 with:
IntFunction<IntUnaryOperator> inFu = x -> y -> x*y;
C. Replace line n1 with:
BiFunction<IntUnaryOperator> inFu = x -> y -> x*y;
D. Replace line n2 with:
IntStream newStream = stream.map(inFu.applyAsInt (10));
Answer: D
Q4. You have been asked to create a ResourceBundle which uses a properties file to localize an application.
Which code example specifies valid keys of menu1 and menu2 with values of File Menu and View Menu?
A. <key name = ‘menu1”>File Menu</key> <key name = ‘menu2”>View Menu</key>
B. <key>menu1</key><value>File Menu</value> <key>menu2</key><value>View Menu</value>
C. menu1, File Menu, menu2, View Menu
D. menu1 = File Menu menu2 = View Menu
Answer: B
Q5. The protected modifier on a Field declaration within a public class means that the field ______________.
A. Cannot be modified
B. Can be read but not written from outside the class
C. Can be read and written from this class and its subclasses only within the same package
D. Can be read and written from this class and its subclasses defined in any package
Answer: D
Reference:
http://beginnersbook.com/2013/05/java-access-modifiers/
Q6. What is the proper way to defined a method that take two int values and returns their sum as an int value?
A. int sum(int first, int second) { first + second; }
B. int sum(int first, second) { return first + second; }
C. sum(int first, int second) { return first + second; }
D. int sum(int first, int second) { return first + second; }
E. void sum (int first, int second) { return first + second; }
Answer: D
Q7. Given the code fragments:
interface CourseFilter extends Predicate<String> {
public default boolean test (String str) {
return str.equals (“Java”);
}
}
and
List<String> strs = Arrays.asList(“Java”, “Java EE”, “Java ME”);
Predicate<String> cf1 = s - > s.length() > 3;
Predicate cf2 = new CourseFilter() { //line n1
public boolean test (String s) {
return s.contains (“Java”);
}
};
long c = strs.stream()
.filter(cf1)
.filter(cf2//line n2
.count();
System.out.println(c);
What is the result?
A. 2
B. 3
C. A compilation error occurs at line n1.
D. A compilation error occurs at line n2.
Answer: A
Q8. Given:
public class product { int id; int price;
public Product (int id, int price) {
this.id = id;
this.price = price;
}
public String toString() { return id + “:” + price; }
}
and the code fragment:
List<Product> products = Arrays.asList(new Product(1, 10),
new Product (2, 30),
new Product (2, 30));
Product p = products.stream().reduce(new Product (4, 0), (p1, p2) -> {
p1.price+=p2.price;
return new Product (p1.id, p1.price);});
products.add(p);
products.stream().parallel()
.reduce((p1, p2) - > p1.price > p2.price ? p1 : p2)
.ifPresent(System.out: :println);
What is the result?
A. 2 : 30
B. 4 : 0
C. 4 : 60
D. 4 : 60
2 : 30
3 : 20
1 : 10
E.
The program prints nothing.
Answer: D