Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Note: Assume required classes and interfaces are imported for all questions. (4

ID: 3712623 • Letter: N

Question

Note: Assume required classes and interfaces are imported for all questions. (4 points) Q1. Circle True or False. ethod (a) A template method in the template method pattern is always a concrete m True False no-parameter (b) When super ) is called in a sub class, it will be an immediate compilation error if a constructor is not available in the immediate super class. True False (c) Although a class has concrete methods only, it can be still defined as an abstract class. True False Consider the following method and inheritance hierarchy to answer the question (d). The getsalary) is a protected method. Faculty and Staff are in different packages. Employee protected double get8alaryo Faculty Staff (d) The following method of the Faculty c lass compiles. True False void somemethod (Staff staff) stem.out.printin(staff.getsalary()):1 Sy

Explanation / Answer

True Yes,a templete method in a templete method pattern is always concrete method. Beccause there will be a base class,which is will declare a concrete method. False When the super class is not having the default constructor and we are calling it from a sub class. then the error wont rise. It will call the constructor if it exists in the super class. If it is not there it simply search for it and ignore it. Thats why no error rises. True I coded the required example and run it. It safely ran wothout any errors. Hence we can define a class as abstract even if there are all concrete methods in it. True The given code is successfully compiled. The protected methods and members can be successfully accesed by the derived classes. hence the code compiles

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote