nerdexam
Oracle

1Z0-804 · Question #19

Given: Which group of method is moved to a new class when implementing the DAO pattern?

The correct answer is D. public Person getPerson(int id) throws Exception. The methods related directly to the entity Person is moved to a new class. Note:DAO Design Pattern Abstracts and encapsulates all access to a data source Manages the connection to the data source to obtain and store data *Makes the code independent of the data sources and data…

Object-Oriented Design Principles

Question

Given:

Which group of method is moved to a new class when implementing the DAO pattern?

Exhibit

1Z0-804 question #19 exhibit

Options

  • Apublic in getId ()
  • Bpublic int getId ()
  • Cpublic void setContractDetails(String contractDetails)
  • Dpublic Person getPerson(int id) throws Exception

How the community answered

(63 responses)
  • A
    16% (10)
  • B
    10% (6)
  • C
    3% (2)
  • D
    71% (45)

Explanation

The methods related directly to the entity Person is moved to a new class. Note:DAO Design Pattern *Abstracts and encapsulates all access to a data source *Manages the connection to the data source to obtain and store data *Makes the code independent of the data sources and data vendors (e.g. plain-text, xml, LDAP, MySQL, Oracle, DB2) Example (here Customer is the main entity): public class Customer { private final String id; private String contactName; private String phone; public void setId(String id) { this.id = id; } public String getId() { return this.id; } public void setContactName(String cn) { this.contactName = cn;} public String getContactName() { return this.contactName; } public void setPhone(String phone) { this.phone = phone; } public String getPhone() { return this.phone; } public interface CustomerDAO { public void addCustomer(Customer c) throws DataAccessException; public Customer getCustomer(String id) throws DataAccessException; public List getCustomers() throws DataAccessException; public removeCustomer(String id) throws DataAccessException; public void modifyCustomer(Customer c) throws DataAccessException; }

Topics

#DAO pattern#data access object#method separation#persistence layer

Community Discussion

No community discussion yet for this question.

Full 1Z0-804 Practice