Abstract Methods and Concrete Methods
016-002 - Abstract Methods and Concrete Methods
Abstract and concrete methods in abstract classes serve different purposes. Abstract methods (declared 'abstract') have no implementation—only signature. Subclasses must implement them: 'abstract void process();'. Concrete methods have full implementations that subclasses inherit. This combination enables partial implementation: define common behavior in concrete methods, require customization through abstract methods. Understanding this distinction enables designing flexible class templates.
Mastering the mix of abstract and concrete methods enables sophisticated template designs. Being able to provide default behavior while requiring specific customization points is powerful. In professional development, this pattern appears in template method designs: the abstract class implements the algorithm skeleton with concrete methods, requiring subclasses to fill in steps via abstract methods. For example, a game framework might provide common game loop logic (concrete) while requiring game-specific update logic (abstract).
By learning abstract and concrete method combinations, you'll design elegant template patterns. Understanding that abstract methods enforce contracts while concrete methods provide reuse helps you structure hierarchies. This knowledge is fundamental to framework design. Prerequisites include understanding abstract classes, inheritance, and method overriding.
Problems (10)
Concrete Methods: Multiple Methods in Calculator Class
# Concrete Methods: Multiple Methods in Calculator <a href="https://javadrill.tech/problems/007">cla...
Abstract and Concrete Methods: Vehicle Class
# Abstract and Concrete Methods: Vehicle <a href="https://javadrill.tech/problems/007">class</a> **...
Abstract and Concrete Methods: Shape Class
# Abstract and Concrete Methods: Shape <a href="https://javadrill.tech/problems/007">class</a> **In...
Abstract and Concrete Methods: Shape Area Calculation
# Abstract and Concrete Methods: Shape Area Calculation **In this problem**, you will create a prog...
Concrete Methods: Point Card Class with State
# Concrete Methods: Point Card <a href="https://javadrill.tech/problems/007">class</a> with State *...
Abstract Class: Concrete Methods
# <a href="https://javadrill.tech/problems/016">abstract <a href="https://javadrill.tech/problems/00...
Abstract and Concrete Methods Together
# Abstract and Concrete Methods Together **In this problem**, you will create a program that define...
Template Method with Abstract Class
# Template <a href="https://javadrill.tech/problems/008">method</a> with <a href="https://javadrill....
Implementing Abstract Methods
# Implementing Abstract Methods **In this problem**, you will create a program that implements abst...
Abstract and Concrete Methods
# Abstract and Concrete Methods **In this problem**: You will define an <a href="https://javadrill....
