Java OCA OCP Practice Question 2311

Question

Which of the following points should you incorporate in your application design?

  • a Create related classes in a single package.
  • b Don't make derived classes overload methods from their base class.
  • c Expose the functionality of your classes using public methods.
  • d Create private methods to work as helper methods for the public methods.


a, c, d

Note

Option (a) is correct.

A package enables you to create a namespace to group related classes and interfaces together.

Option (b) is incorrect.

A base class overloads its base class method, as required.

Making derived classes overload their base class methods doesn't make it an incorrect or inefficient design.

Options (c) and (d) are also correct.

The functionality of your classes should be exposed using the public methods.

The private methods are called within the class in which they're defined.

They usually work as helper methods.




PreviousNext

Related