Oracle 1z0-804 Exam Practice Questions (P. 4)
- Full Access (150 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
Which four are true about enums?
- AAn enum is typesafe.
- BAn enum cannot have public methods or fields.
- CAn enum can declare a private constructor.
- DAll enums implicitly implement Comparable.
- EAn enum can subclass another enum.
- FAn enum can implement an interface.
Correct Answer:
ACDF
C: The constructor for an enum type must be package-private or private access.
Reference: Java Tutorials,Enum Types
ACDF
C: The constructor for an enum type must be package-private or private access.
Reference: Java Tutorials,Enum Types
send
light_mode
delete
Question #17
Given:

Which statement, inserted at line 8, enables the code to compile?

Which statement, inserted at line 8, enables the code to compile?
- Anew Task().new Counter().increment();
- Bnew Task().Counter().increment();
- Cnew Task.Counter().increment();
- DTask.Counter().increment();
- ETask.Counter.increment();
Correct Answer:
C
C
send
light_mode
delete
Question #18
Which represents part of a DAO design pattern?
- Ainterface EmployeeDAO { int getID(); Employee findByID (intid); void update(); void delete(); }
- Bclass EmployeeDAO { int getID() { return 0;} Employee findByID (int id) { return null;} void update () {} void delete () {} }
- Cclass EmployeeDAO { void create (Employee e) {} void update (Employee e) {} void delete (int id) {} Employee findByID (int id) {return id} }
- Dinterface EmployeeDAO { void create (Employee e); void update (Employee e); void delete (int id); Employee findByID (int id); }
- Einterface EmployeeDAO { void create (Connection c, Employee e); void update (Connection c, Employee e); void delete (Connection c, int id); Employee findByID (Connection c, int id); } D
Correct Answer:
Explanation
Explanation
send
light_mode
delete
Question #19
Given:

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

Which group of method is moved to a new class when implementing the DAO pattern?
- Apublic in getId () public String getContractDetails () public Void setContractDetails(String contactDetails) public String getName () public void setName (String name)
- Bpublic int getId () public String getContractDetails() public String getName() public Person getPerson(int id) throws Exception
- Cpublic void setContractDetails(String contractDetails) public void setName(String name)
- Dpublic Person getPerson(int id) throws Exception public void createPerson(Person p) throws Exception public void deletePerson(int id) throws Exception public void updatePerson(Person p) throws Exception
Correct Answer:
D
The methods related directly to the entity Person is moved to a new class.
CRUD -
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 void removeCustomer(String id) throws DataAccessException; public void modifyCustomer(Customer c) throws
DataAccessException; }
D
The methods related directly to the entity Person is moved to a new class.
CRUD -
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 void removeCustomer(String id) throws DataAccessException; public void modifyCustomer(Customer c) throws
DataAccessException; }
send
light_mode
delete
Question #20
Given:

Which three are true?

Which three are true?
- ABasicCar uses composition.
- BSuperCar uses composition.
- CBasicCar is-a Car.
- DSuperCar is-a Car.
- ESuperCar takes advantage of polymorphism
- FBasicCar has-a Car
Correct Answer:
BCE
B: The relationship modeled by composition is often referred to as the "has-a" relationship. Here SuperCar has-a Car.
C:The relationship modeled by inheritance is often referred to as the "is-a" relationship. Modeling an is-a relationship is called inheritance because the subclass inherits the interface and, by default, the implementation of the superclass. Inheritance of interface guarantees that a subclass can accept all the same messages as its superclass. A subclass object can, in fact, be used anywhere a superclass object is called for. E:The polymorphic method call allows one type to express its distinction from another, similar type, as long as they're both derived from the same base type. This distinction is expressed through differences in behavior of the methods that you can call through the base class.
BCE
B: The relationship modeled by composition is often referred to as the "has-a" relationship. Here SuperCar has-a Car.
C:The relationship modeled by inheritance is often referred to as the "is-a" relationship. Modeling an is-a relationship is called inheritance because the subclass inherits the interface and, by default, the implementation of the superclass. Inheritance of interface guarantees that a subclass can accept all the same messages as its superclass. A subclass object can, in fact, be used anywhere a superclass object is called for. E:The polymorphic method call allows one type to express its distinction from another, similar type, as long as they're both derived from the same base type. This distinction is expressed through differences in behavior of the methods that you can call through the base class.
send
light_mode
delete
All Pages