Visit Official SkillCertPro Website :-
Java SE 8 Programmer II (1Z0-809) Practice Tests 2023. Contains 750+ exam questions to pass the exam in first attempt.
For a full set of 750+ questions. Go to
https://skillcertpro.com/product/java-se-8-programmer-ii-1z0-809-exam-questions/
SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
SkillCertPro updates exam questions every 2 weeks.
You will get life time access and life time free updates
SkillCertPro assures 100% pass guarantee in first attempt.
Question 1:
Which of the following creates a Path object pointing to c:/temp/exam? (Choose all that apply.)
A. new Path(“c:/temp/exam“)
B. new Path(“c:/temp“, “exam“)
C. Files.get(“c:/temp/exam“)
D. Files.get(“c:/temp“, “exam“)
E. Paths.get(“c:/temp/exam“)
F. Paths.get(“c:/temp“, “exam“)
Answer: E, F
Explanation:
since Paths must be created using the Paths.get() method. This method takes a varargs String parameter, so you can pass as many path segments to it as you like.
A and B are incorrect because you cannot construct a Path directly. C and D are incorrect because the Files class works with Path objects but does not create them from Strings.
Question 2:
Given the following statements:
I. A nonempty directory can usually be deleted using Files. Delete
II. A nonempty directory can usually be moved using Files. Move
III. A nonempty directory can usually be copied using Files. Copy
which of the following is true?
A. I only
B. II only
C. III only
D. I and II only
E. II and III only
F. I and III only
Answer: E
Explanation:
A directory containing files or subdirectories is copied or moved in its entirety. Directories can only be deleted if they are empty. Trying to delete a nonempty directory will throw a DirectoryNotEmptyException. The question says usually because copy and move success depends on file permissions. Think about the most common cases when encountering words such as usually on the exam.
Question 3:
Which of the following are true? (Choose all that apply.)
A. The class AbstractFileAttributes applies to all operating systems
B. The class BasicFileAttributes applies to all operating systems
C. The class DosFileAttributes applies to Windows-based operating systems
D. The class WindowsFileAttributes applies to Windows-based operating systems
E. The class PosixFileAttributes applies to all Linux/UNIX-based operating systems
F. The class UnixFileAttributes applies to all Linux/UNIX-based operating systems
Answer: B, C, E
Explanation:
BasicFileAttributes is the general superclass. DosFileAttributes subclasses BasicFileAttributes for Windows operating systems. PosixFileAttributes subclasses BasicFileAttributes for UNIX/Linux/Mac operating systems.
A, D, and F are incorrect because no such classes exist.
Question 4:
Assume all the files referenced by these paths exist:
Path a = Paths.get(“c:/temp/dir/a.txt“);
Path b = Paths.get(“c:/temp/dir/subdir/b.txt“);
What is the correct string to pass to PathMatcher to match both these files?
A. “glob:*/*.txt“
B. “glob:**.txt“
C. “glob:*.txt“
D. “glob:/*/*.txt“
E. “glob:/**.txt“
F. “glob:/*.txt“
Answer: B
Explanation:
** matches zero or more characters, including multiple directories.
A is incorrect because */ only matches one directory. It will match temp but not c:/temp, let alone c:/temp/dir. C is incorrect because *.txt only matches filenames and not directory paths. D, E, and F are incorrect because the paths we want to match do not begin with a slash.
Question 5:
Given:
import java.io.*;
class Keyboard { }
public class Computer implements Serializable {
private Keyboard k = new Keyboard();
public static void main(String[] args) {
Computer c = new Computer();
c.storeIt(c);
}
void storeIt(Computer c) {
try {
ObjectOutputStream os = new ObjectOutputStream(
new FileOutputStream(“myFile“));
os.writeObject(c);
os.close();
System.out.println(“done“);
} catch (Exception x) {System.out.println(“exc“); }
}
}
What is the result? (Choose all that apply.)
A. exc
B. done
C. Compilation fails
D. Exactly one object is serialized
E. Exactly two objects are serialized
Answer: A
Explanation:
An instance of type Computer has-a Keyboard. Because Keyboard doesnt implement Serializable, any attempt to serialize an instance of Computer will cause an exception to be thrown.
B, C, D, and E are incorrect based on the above. If Keyboard did implement Serializable, then two objects would have been serialized.
For a full set of 750+ questions. Go to
https://skillcertpro.com/product/java-se-8-programmer-ii-1z0-809-exam-questions/
SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
SkillCertPro updates exam questions every 2 weeks.
You will get life time access and life time free updates
SkillCertPro assures 100% pass guarantee in first attempt.
Question 6:
Given:
public static void main(String[] args) {
// INSERT DECLARATION HERE
for (int i = 0; i <= 10; i++) {
List row = new ArrayList();
for (int j = 0; j <= 10; j++)
row.add(i * j);
table.add(row);
}
for (List row : table)
System.out.println(row);
}
Which statements could be inserted at // INSERT DECLARATION HERE to allow this code to compile and run? (Choose all that apply.)
A. List> table = new List>();
B. List> table = new ArrayList>();
C. List> table = new ArrayList>();
D. List
E. List
F. List
Answer: B
Explanation:
Because List is an interface, so you can’t say new List(), regardless of any generic types. D, E, and F are incorrect because List only takes one type parameter (a Map would take two, not a List). C is tempting, but incorrect. The type argument <List> must be the same for both sides of the assignment, even though the constructor new ArrayList() on the right side is a subtype of the declared type List on the left.
Question 7:
Given:
public static void before() {
Set set = new TreeSet();
set.add(“2“);
set.add(3);
set.add(“1“);
Iterator it = set.iterator();
while (it.hasNext())
System.out.print(it.next() + “ “);
}
Which statements are true?
A. The before() method will print 1 2
B. The before() method will print 1 2 3
C. The before() method will print three numbers, but the order cannot be determined
D. The before() method will not compile
E. The before() method will throw an exception at runtime
Answer: E
Explanation:
You can’t put both Strings and ints into the same TreeSet. Without generics, the compiler has no way of knowing what type is appropriate for this TreeSet, so it allows everything to compile. At runtime, the TreeSet will try to sort the elements as they’re added, and when it tries to compare an Integer with a String, it will throw a ClassCastException. Note that although the before() method does not use generics, it does use autoboxing. Watch out for code that uses some new features and some old features mixed together.
Question 8:
Which collection class(es) allows you to grow or shrink its size and provides indexed access to its elements, but whose methods are not synchronized? (Choose all that apply.)
A. java.util.HashSet
B. java.util.LinkedHashSet
C. java.util.List
D. java.util.ArrayList
E. java.util.Vector
F. java.util.PriorityQueue
Answer: D
Explanation:
All of the collection classes allow you to grow or shrink the size of your collection. ArrayList provides an index to its elements. The newer collection classes tend not to have synchronized methods. Vector is an older implementation of ArrayList functionality and has synchronized methods; it is slower than ArrayList.
A, B, C, E, and F are incorrect based on the logic described earlier. C, List, is an interface, and F and G, PriorityQueue and ArrayDeque, do not offer access by index.
Question 9:
Given the proper import statement(s) and
13. PriorityQueue pq = new PriorityQueue();
14. pq.add(“2“);
15. pq.add(“4“);
16. System.out.print(pq.peek() + “ “);
17. pq.offer(“1“);
18. pq.add(“3“);
19. pq.remove(“1“);
20. System.out.print(pq.poll() + “ “);
21. if(pq.remove(“2“)) System.out.print(pq.poll() + “ “);
22. System.out.println(pq.poll() + “ “ + pq.peek());
What is the result?
A. 2 2 3 3
B. 2 2 3 4
C. 4 3 3 4
D. 2 2 3 3 3
E. 4 3 3 3 3
F. 2 2 3 3 4
Answer: B
Explanation:
For the sake of the exam, add() and offer() both add to (in this case) naturally sorted queues. The calls to poll() both return and then remove the first item from the queue, so the test fails.
Question 10:
Which are true about a static nested class? (Choose all that apply.)
A. You must have a reference to an instance of the enclosing class in order to instantiate it
B. It does not have access to nonstatic members of the enclosing class
C. Its variables and methods must be static
D. If the outer class is named MyOuter and the nested class is named MyInner, it can be instantiated using new MyOuter.MyInner();
E. It must extend the enclosing class
Answer: B, D
Explanation:
A static nested class is not tied to an instance of the enclosing class, and thus can’t access the nonstatic members of the class (just as a static method can’t access nonstatic members of a class). D uses the correct syntax for instantiating a static nested class.
A is incorrect because static nested classes do not need (and can’t use) a reference to an instance of the enclosing class. C is incorrect because static nested classes can declare and define nonstatic members. E is wrong because it just is. There’s no rule that says an inner or nested class has to extend anything.
For a full set of 750+ questions. Go to
https://skillcertpro.com/product/java-se-8-programmer-ii-1z0-809-exam-questions/
SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
SkillCertPro updates exam questions every 2 weeks.
You will get life time access and life time free updates
SkillCertPro assures 100% pass guarantee in first attempt.