Oracle 1z0-809 - Java SE 8 Programmer II
Given:
Which option fails?
Given the content of /resourses/Message.properties:
welcome1=â€Good day!â€
and given the code fragment:
Properties prop = new Properties ();
FileInputStream fis = new FileInputStream (“/resources/Message.propertiesâ€);
prop.load(fis);
System.out.println(prop.getProperty(“welcome1â€));
System.out.println(prop.getProperty(“welcome2â€, “Testâ€));//line n1
System.out.println(prop.getProperty(“welcome3â€));
What is the result?
Given the code fragment:
Stream
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?
Given:
class Bird {
public void fly () { System.out.print(“Can flyâ€); }
}
class Penguin extends Bird {
public void fly () { System.out.print(“Cannot flyâ€); }
}
and the code fragment:
class Birdie {
public static void main (String [ ] args) {
fly( ( ) -> new Bird ( ));
fly (Penguin : : new);
}
/* line n1 */
}
Which code fragment, when inserted at line n1, enables the Birdie class to compile?
Given the code fragment:
Which statement can be inserted into line n1 to print 1,2; 1,10; 2,20;?
Given the code fragment:
List
empDetails.stream()
.filter(s-> s.contains(“râ€))
.sorted()
.forEach(System.out::println); //line n1
What is the result?
Given that course.txt is accessible and contains:
Course : : Java
and given the code fragment:
public static void main (String[ ] args) {
int i;
char c;
try (FileInputStream fis = new FileInputStream (“course.txtâ€);
InputStreamReader isr = new InputStreamReader(fis);) {
while (isr.ready()) { //line n1
isr.skip(2);
i = isr.read ();
c = (char) i;
System.out.print(c);
}
} catch (Exception e) {
e.printStackTrace();
}
}
What is the result?
Given the content of the employee.txt file:
Every worker is a master.
Given that the employee.txt file is accessible and the file allemp.txt does NOT exist, and the code fragment:
What is the result?
Given the code fragments:
and
What is the result?
Given the code fragment:
Which should be inserted into line n1 to print Average = 2.5?