In Template pattern, a summary class expose define way(s)/template(s) to execute its methods. Its subclasses can override the way implementation as per need but the invocation is to be in the same way as define by an abstract class. This pattern comes under behaviour pattern group.
We are going to make a Game concrete class defining operations with a template method set to be finishing so that it cannot be override. Cricket and Football are concrete classes that expand Game and override its methods.
TemplatePatternDemo, our demo class, will use Game to express use of template pattern.
Create an abstract class with a template method being finishing.
Create concrete classes extend the beyond class.
Apply the Game's template method play () to express a define way of playing game.
Verify the output.
Design Patterns Related Interview Questions
|Java Script Interview Questions||AJAX Interview Questions|
|Graphic Design Interview Questions||Adobe Indesign Interview Questions|
|Java-Multithreading Interview Questions||Database Design Interview Questions|
|Compiler Design Interview Questions||CSS Advanced Interview Questions|
|Java Design Patterns Interview Questions||Hardware design Interview Questions|
|Material Design Lite Interview Questions||Object Oriented Analysis and Design Interview Questions|
|Standard Template Library (STL) Interview Questions|
Design Patterns Tutorial
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.