Oracle 1z0-809 Exam Practice Questions (P. 4)
- Full Access (248 questions)
- Six months of Premium Access
- Access to one million comments
- Seamless ChatGPT Integration
- Ability to download PDF files
- Anki Flashcard files for revision
- No Captcha & No AdSense
- Advanced Exam Configuration
Question #16
Given the code fragment:
Map<Integer, String> books = new TreeMap<>();
books.put (1007, "A");
books.put (1002, "C");
books.put (1001, "B");
books.put (1003, "B");
System.out.println (books);
What is the result?
Map<Integer, String> books = new TreeMap<>();
books.put (1007, "A");
books.put (1002, "C");
books.put (1001, "B");
books.put (1003, "B");
System.out.println (books);
What is the result?
- A{1007 = A, 1002 = C, 1001 = B, 1003 = B}
- B{1001 = B, 1002 = C, 1003 = B, 1007 = A}Most Voted
- C{1002 = C, 1003 = B, 1007 = A}
- D{1007 = A, 1001 = B, 1003 = B, 1002 = C}
Correct Answer:
B
Reference:
TreeMap inherits SortedMap and automatically sorts the element's key
B
Reference:
TreeMap inherits SortedMap and automatically sorts the element's key
send
light_mode
delete
Question #17
Given:
class Book {
int id;
String name;
public Book (int id, String name) {
this.id = id;
this.name = name;
}
public boolean equals (Object obj) { //line n1
boolean output = false;
Book b = (Book) obj;
if (this.name.equals(b name))}
output = true;
}
return output;
}
}
and the code fragment:
Book b1 = new Book (101, "Java Programing");
Book b2 = new Book (102, "Java Programing");
System.out.println (b1.equals(b2)); //line n2
Which statement is true?
class Book {
int id;
String name;
public Book (int id, String name) {
this.id = id;
this.name = name;
}
public boolean equals (Object obj) { //line n1
boolean output = false;
Book b = (Book) obj;
if (this.name.equals(b name))}
output = true;
}
return output;
}
}
and the code fragment:
Book b1 = new Book (101, "Java Programing");
Book b2 = new Book (102, "Java Programing");
System.out.println (b1.equals(b2)); //line n2
Which statement is true?
- AThe program prints true.Most Voted
- BThe program prints false.
- CA compilation error occurs. To ensure successful compilation, replace line n1 with: boolean equals (Book obj) {
- DA compilation error occurs. To ensure successful compilation, replace line n2 with: System.out.println (b1.equals((Object) b2));
Correct Answer:
A
A
send
light_mode
delete
Question #18
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?
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?
- AGood day! Test followed by an Exception stack trace
- BGood day! followed by an Exception stack trace
- CGood day! Test nullMost Voted
- DA compilation error occurs at line n1.
Correct Answer:
C
C
send
light_mode
delete
Question #19
Which action can be used to load a database driver by using JDBC3.0?
- AAdd the driver class to the META-INF/services folder of the JAR file.
- BInclude the JDBC driver class in a jdbc.properties file.
- CUse the java.lang.Class.forName method to load the driver class.Most Voted
- DUse the DriverManager.getDriver method to load the driver class.
Correct Answer:
C
C
send
light_mode
delete
Question #20
Given the code fragment:
Path p1 = Paths.get("/Pics/MyPic.jpeg");
System.out.println (p1.getNameCount() +
":" + p1.getName(1) +
":" + p1.getFileName());
Assume that the Pics directory does NOT exist.
What is the result?
Path p1 = Paths.get("/Pics/MyPic.jpeg");
System.out.println (p1.getNameCount() +
":" + p1.getName(1) +
":" + p1.getFileName());
Assume that the Pics directory does NOT exist.
What is the result?
- AAn exception is thrown at run time.
- B2:MyPic.jpeg: MyPic.jpegMost Voted
- C3:.:MyPic.jpeg
- D2:Pics: MyPic.jpeg
Correct Answer:
B
B
send
light_mode
delete
All Pages