LRP-614 practice question 7 of 25

A class that extends MVCPortlet must implement:

Full set: 144 questions
Answer options
A: init()
B: doView()
C: doEdit()
D: processAction()
E: All of the above
F: None of the above Correct answer
Correct Answer:
F. None of the above
Explanation

The com.liferay.portal.kernel.portlet.bridges.mvc.MVCPortlet class is a concrete Java class, not an abstract one. It provides default, non-abstract implementations for all portlet lifecycle methods, including init(), doView(), doEdit(), and processAction(). According to the Java Language Specification, a subclass is only required to implement a method if that method is declared as abstract in the superclass. Since MVCPortlet and its parent classes provide concrete implementations for all these methods, a class that extends MVCPortlet is not syntactically required to override any of them for the code to compile. While overriding doView() is standard practice to render content, it is not a mandatory implementation from a language or framework perspective.

Why Incorrect

A. init(): This method is inherited from GenericPortlet and has a concrete, empty implementation. Overriding it is optional for custom initialization logic.
B. doView(): MVCPortlet provides a default implementation that forwards to a JSP. While essential for a functional portlet, overriding it is not a compile-time requirement.
C. doEdit(): Similar to doView(), MVCPortlet provides a default implementation for the EDIT mode. It only needs to be overridden if custom edit functionality is required.
D. processAction(): MVCPortlet provides a default implementation for handling actions. It is overridden to process form submissions or other user actions, but it is not mandatory.
E. All of the above: This is incorrect because none of the individual methods are required to be implemented.

References

1. Liferay Portal 6.2 CE Javadoc: The official Javadoc for com.liferay.util.bridges.mvc.MVCPortlet shows it as a public class, not an abstract class. It also documents the concrete implementations of methods like doView(RenderRequest, RenderResponse).

Source: Liferay Portal 6.2 CE Javadoc, com.liferay.util.bridges.mvc.MVCPortlet class documentation. (Note: Direct links to old Javadocs are unstable, but this can be verified in any Liferay 6.1/6.2 source code distribution).

2. The Java® Language Specification, Java SE 8 Edition: This specification defines the rules of inheritance and abstract methods.

Reference: Section 8.1.1.1, "abstract Classes". It states that a class must be declared abstract if it does not implement all abstract methods from its superclasses or superinterfaces. Since MVCPortlet is not abstract, it and its superclasses provide implementations for all required methods.

3. Official Liferay Developer Documentation: Tutorials on creating MVC portlets demonstrate overriding doView as a best practice for implementing the view logic, but do not state it as a mandatory compile-time requirement. The default behavior relies on including a JSP file (e.g., view.jsp).

Reference: Liferay Developer Network (dev.liferay.com) tutorials for Liferay 6.1/6.2, "Creating a Portlet" section. The code examples show the common pattern of overriding, not a language-enforced rule.

Scroll to Top