Java OCA OCP Practice Question 380

Question

Given:

public class Main {
  private static final Main f = new Main();
  public static Main c() {
    return f;
  }
  public void update(Main a) { }

  public void delete(Main a) { }
}

Which design pattern or principle is implemented?

  • A. Coupling
  • B. DAO
  • C. Factory
  • D. IS-A
  • E. Object composition
  • F. Singleton


F is correct.

Note

The singleton pattern is identifiable by the static variable for the single instance and the accessor returning it.

B is incorrect because there is no interface.

The class just happens to have methods update() and delete(), which are similar to those found in a DAO.




PreviousNext

Related