Free Oracle 1Z0-809 Exam Questions (page: 6)

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?

  1. The program prints true.
  2. The program prints false.
  3. A compilation error occurs. To ensure successful compilation, replace line n1 with:
    boolean equals (Book obj) {
  4. A compilation error occurs. To ensure successful compilation, replace line n2 with:
    System.out.println (b1.equals((Object) b2));

Answer(s): A



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?

  1. Good day!
    Test
    followed by an Exception stack trace
  2. Good day!
    followed by an Exception stack trace
  3. Good day! Test null
  4. A compilation error occurs at line n1.

Answer(s): C



Which action can be used to load a database driver by using JDBC3.0?

  1. Add the driver class to the META-INF/services folder of the JAR file.
  2. Include the JDBC driver class in a jdbc.properties file.
  3. Use the java.lang.Class.forName method to load the driver class.
  4. Use the DriverManager.getDriver method to load the driver class.

Answer(s): C



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?

  1. An exception is thrown at run time.
  2. 2:MyPic.jpeg: MyPic.jpeg
  3. 1:Pics:/Pics/ MyPic.jpeg
  4. 2:Pics: MyPic.jpeg

Answer(s): B



Viewing page 6 of 42



Post your Comments and Discuss Oracle 1Z0-809 exam prep with other Community members:

1Z0-809 Exam Discussions & Posts