Practicetest 1Z0-804 Oracle it-exams
Practicetest 1Z0-804 Oracle it-exams
IT Exam,IT Certification,braindump,original questions, question pool,document, braindump, test questions, test question, dumps, test answers, it-exams.com, preparation, pdf, certification questions, answers Certification, certification test, practice test, exam dumps, certification training, answers real questions
1Z0-804 Java SE 7 Programmer II Exam our products come with a 100% guarantee of success. We hold this claim because of the highly dedicated and expert team that we have and because of our past performance.
Practicetest 1Z0-804 Oracle it-exams
QUESTION NO: 1
Given:
import java.io.File;
import java.nio.file.Path;
public class Test12 {
static String displayDetails(String path, int location) {
Path p = new File(path).toPath();
String name = p.getName(location).toString();
return name;
}
public static void main(String[] args) {
String path = "project//doc//index.html";
String result = displayDetails(path,2);
System.out.print(result);
}
}
What is the result?
A. doc
B. index.html
C. an IllegalArgumentException is thrown at runtime.
D. An InvalidPthException is thrown at runtime.
E. Compilation fails.
Answer: B
QUESTION NO: 2
Given 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) {
e.printStackTrace();
}
Why is there no output when otherMethod is called?
A. An exception other than IOException is thrown.
B. Standard error is not mapped to the console.
C. There is a compilation error.
D. The exception is suppressed.
Answer: D
Explanation: The code compiles fine
The line FileInputStream fis = new FileInputStream(file))
will fail at runtime since file is an empty string.
Note:
public void printStackTrace()
Prints this throwable and its backtrace to the standard error stream.
QUESTION NO: 3
Given the code fragment:
public void ReadFile (String source) {
char[] c = new char [128];
int cLen = c.length;
try (FileReader fr = new FileReader (source)) {
int count = 0;
int read = 0;
while ((read = fr.read(c)) != -1) {
count += read;
}
System.out.println("Read: " + count + " characters.");
} catch (IOException i) {
}
What change should you make to this code to read and write strings instead of character arrays?
A. ChangeFileReader to Readers.
B. ChangeFileReader to DataReader.
C. ChangeFileReader to File.
D. ChangeFileReader to BufferReader.
Answer: D
Practicetest 1Z0-804 Oracle it-exams
IT Exam,IT Certification,braindump,original questions, question pool,document, braindump, test questions, test question, dumps, test answers, it-exams.com, preparation, pdf, certification questions, answers Certification, certification test, practice test, exam dumps, certification training, answers real questions
1Z0-804 Java SE 7 Programmer II Exam our products come with a 100% guarantee of success. We hold this claim because of the highly dedicated and expert team that we have and because of our past performance.
Practicetest 1Z0-804 Oracle it-exams
QUESTION NO: 1
Given:
import java.io.File;
import java.nio.file.Path;
public class Test12 {
static String displayDetails(String path, int location) {
Path p = new File(path).toPath();
String name = p.getName(location).toString();
return name;
}
public static void main(String[] args) {
String path = "project//doc//index.html";
String result = displayDetails(path,2);
System.out.print(result);
}
}
What is the result?
A. doc
B. index.html
C. an IllegalArgumentException is thrown at runtime.
D. An InvalidPthException is thrown at runtime.
E. Compilation fails.
Answer: B
QUESTION NO: 2
Given 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) {
e.printStackTrace();
}
Why is there no output when otherMethod is called?
A. An exception other than IOException is thrown.
B. Standard error is not mapped to the console.
C. There is a compilation error.
D. The exception is suppressed.
Answer: D
Explanation: The code compiles fine
The line FileInputStream fis = new FileInputStream(file))
will fail at runtime since file is an empty string.
Note:
public void printStackTrace()
Prints this throwable and its backtrace to the standard error stream.
QUESTION NO: 3
Given the code fragment:
public void ReadFile (String source) {
char[] c = new char [128];
int cLen = c.length;
try (FileReader fr = new FileReader (source)) {
int count = 0;
int read = 0;
while ((read = fr.read(c)) != -1) {
count += read;
}
System.out.println("Read: " + count + " characters.");
} catch (IOException i) {
}
What change should you make to this code to read and write strings instead of character arrays?
A. ChangeFileReader to Readers.
B. ChangeFileReader to DataReader.
C. ChangeFileReader to File.
D. ChangeFileReader to BufferReader.
Answer: D
Practicetest 1Z0-804 Oracle it-exams
nina008 - 23. Dez, 05:17