nerdexam
Oracle

1Z0-860 · Question #245

Given the following code in an EJB 3.0 session bean: 10. @Resource(name="jdbc/employeeDB") 11. private DataSource dataSource; 12. 13. public void lookupEmployee(String id) { 14. InitialContext ic =…

The correct answer is E. Object obj = ic.lookup("java:comp/env/jdbc/employeeDB"). See the full explanation below for the reasoning.

Question

Given the following code in an EJB 3.0 session bean: 10. @Resource(name="jdbc/employeeDB") 11. private DataSource dataSource; 12. 13. public void lookupEmployee(String id) { 14. InitialContext ic = new InitialContextO; 15. // insert code here 16. DataSource ds = (DataSource) obj; 17.} Which code, inserted at Line 15, portably looks up the injected resource?

Options

  • AObject obj = ic.lookup("employeeDB");
  • BObject obj = ic.lookup("dataSource");
  • CObject obj = ic.lookup("jdbc/employeeDB");
  • DObject obj = ic.lookup("javacomp/env/employeeDB");
  • EObject obj = ic.lookup("java:comp/env/jdbc/employeeDB");

How the community answered

(39 responses)
  • A
    8% (3)
  • B
    15% (6)
  • C
    3% (1)
  • D
    3% (1)
  • E
    72% (28)

Community Discussion

No community discussion yet for this question.

Full 1Z0-860 Practice