Oracle
1Z0-805 · Question #93
Given the fragment: public class CustomerApplication { public static void main (String args[]) { CustomerDAO custDao= new CustomerDAOMemoryImpl(); // Line 3 // ... other methods } } Which two valid…
The correct answer is B. CustomerDAO custDao = (CustomerDAO) new Object (); E. CustomerDAO custDao = customerDAOFactory.getInstance(). See the full explanation below for the reasoning.
Question
Given the fragment:
public class CustomerApplication { public static void main (String args[]) { CustomerDAO custDao= new CustomerDAOMemoryImpl(); // Line 3 // ... other methods } } Which two valid alternatives to line 3 would decouple this application from a specific implementation of CustomerDAO?
Options
- ACustomerDAO custDao = CustomerDAO();
- BCustomerDAO custDao = (CustomerDAO) new Object ();
- CCustomerDAO custDao = CustomerDAO.getInstance();
- DCustomerDAO custDao = (CustomerDAO) new CustomerDAOmemoryImp1();
- ECustomerDAO custDao = customerDAOFactory.getInstance();
How the community answered
(21 responses)- A5% (1)
- B81% (17)
- C5% (1)
- D10% (2)
Community Discussion
No community discussion yet for this question.