Given the code fragment:
public void infected() {
System.out.print("before ");
try {
int i = 1/0;
System.out.print("try ");
} catch(Exception e) {
System.out.print("catch ");
throw e;
} finally {
System.out.print("finally ");
}
System.out.print("after ");
}
What is the result when infected() is invoked?
A. before try catch finally afterWhich two are true about Singletons?
A. A Singleton must implement serializable.Given the code fragment:
public class Test {
public static void main(String[] args) {
Path dir = Paths.get("D:\\company");
//insert code here. Line ***
for (Path entry: stream) {
System.out.println(entry.getFileName());
}
} catch (IOException e) {
System.err.println("Caught IOException: " + e.getMessage());
}
}
Which two try statements, when inserted at line ***, enable you to print files with the extensions.java, .htm, and .jar.
A. try (DirectoryStream stream = Files.newDirectoryStream(dir, "*. {java, htm, jar}")) {Given:
class Erupt implements Runnable {
public void run() {
System.out.print(Thread.currentThread().getName());
}
}
public class Yellowstone {
static Erupt e = Erupt();
Yellowstone() { new Thread(e, "const").start(); } // line A
public static void main(String[] args) {
new Yellowstone();
new Faithful().go();
}
static class Faithful {
void go() { new Thread(e, "inner").start(); } // line B
}
}
What is the result?
A. Both const and inner will be in the output.Which four are syntactically correct?
A. package abc; package def; import Java.util . * ; public class Test { }Given:
interface Event {
String getCategory();
}
public class CueSports {
public String getCategory() {
return "Cue sports";
}
}
public class Snooker extends CueSports implements Event { // Line 9
public static void main(String[] args) { Event obj1 = new Snooker(); // Line 11
CueSports obj2 = new Snooker(); // Line 12
System.out.print(obj1.GetCategory() + ", " + obj2.getCategory());
}
}
What is the result?
A. Cue sports, Cue sportsWhich is a key aspect of composition?
A. Using inheritanceGiven the code fragment:
public void otherMethod() {
printFile("");
}
public void printFile(String file) {
try (FileInputStream fis = new FileInputStream(file)) {
System.out.println (fis.read());
} catch (IOException e) {
A. printStackTrace(); } Why is there no output when otherMethod is called?Select four examples that initialize a NumberFormat reference using a factory.
A. NumberFormat nf1 = new DecimalFormat();Given the existing destination file, a source file only 1000 bytes long, and the code fragment:
public void process (String source, String destination) { try (InputStream fis = new FileInputStream(source); OutputStream fos = new FileOutputStream(destination)
) {
byte [] buff = new byte[2014];
int i;
while ((i = fis.read(buff)) != -1) {
fos.write(buff,0,i); // line ***
}
} catch (IOException e) {
System.out.println(e.getClass());
}
}
What is the result?
A. Overrides the content of the destination file with the source file contentNowadays, the certification exams become more and more important and required by more and more enterprises when applying for a job. But how to prepare for the exam effectively? How to prepare for the exam in a short time with less efforts? How to get a ideal result and how to find the most reliable resources? Here on Vcedump.com, you will find all the answers. Vcedump.com provide not only Oracle exam questions, answers and explanations but also complete assistance on your exam preparation and certification application. If you are confused on your 1Z0-804 exam preparations and Oracle certification application, do not hesitate to visit our Vcedump.com to find your solutions here.