what is concrete and abstract method

"What Are Concrete & Abstract Methods: A Comprehensive Guide"

By Robert Garcia
AD

In the realm of computer programming, the terms "concrete method" and "abstract method" are fundamental concepts that every developer should understand. They are integral to object-oriented programming (OOP) and help in creating modular, reusable, and efficient code. Let's delve into the world of methods, exploring what concrete and abstract methods are, their differences, and their roles in OOP.

Understanding Methods in Object-Oriented Programming

Before we dive into concrete and abstract methods, let's ensure we're on the same page regarding methods in OOP. A method is essentially a function that's associated with an object. It defines the behavior of the object and can access and modify the object's properties. Methods are defined within classes and are invoked on objects created from those classes.

Concrete Methods: The Workhorses of OOP

Concrete methods, also known as regular or non-abstract methods, are methods that contain a method body, i.e., the code that performs a specific task. They are the workhorses of any application, as they are responsible for the actual processing and computation. Here's a simple example in Java:

AD
Concrete-Representational-Abstract Method
Concrete-Representational-Abstract Method
How Montessori Guides Learning From the Concrete to the Abstract
How Montessori Guides Learning From the Concrete to the Abstract
a table topped with lots of different types of legos and building blocks on top of each other
a table topped with lots of different types of legos and building blocks on top of each other
```java public class Dog { public void bark() { System.out.println("The dog says: Woof!"); } } ```

In this example, the `bark` method is a concrete method. It has a method body that prints a message to the console.

Characteristics of Concrete Methods

  • They have a method body, i.e., the code that performs a specific task.
  • They can be invoked on objects created from the class.
  • They are not declared with the `abstract` keyword.

Abstract Methods: The Blueprints of OOP

Abstract methods, on the other hand, do not have a method body. They are declared with the `abstract` keyword and are intended to serve as a blueprint for concrete methods in subclasses. Abstract methods are used to achieve abstraction, which is one of the key principles of OOP. Here's an example:

How We Help Kids Move On To Abstract Ideas From Concrete Activities
How We Help Kids Move On To Abstract Ideas From Concrete Activities
Concrete thinking style
Concrete thinking style
Teaching Math by Age: Concrete to Abstract
Teaching Math by Age: Concrete to Abstract
```java public abstract class Animal { public abstract void makeSound(); } ```

In this example, the `makeSound` method is an abstract method. It does not have a method body, and any class that extends `Animal` must provide an implementation for this method.

Characteristics of Abstract Methods

  • They do not have a method body.
  • They are declared with the `abstract` keyword.
  • They must be implemented by any non-abstract subclasses.

Concrete vs Abstract Methods: A Comparison

Concrete Methods Abstract Methods
Have a method body Do not have a method body
Can be invoked on objects Cannot be invoked on objects
Not declared with the `abstract` keyword Declared with the `abstract` keyword
Perform a specific task Serve as a blueprint for concrete methods

Understanding the difference between concrete and abstract methods is crucial for effective OOP. Concrete methods are used to implement specific behaviors, while abstract methods are used to define a common interface or contract that subclasses must adhere to.

AD

In conclusion, concrete and abstract methods play distinct yet complementary roles in OOP. They help in creating flexible, maintainable, and extensible code. By mastering these concepts, you'll be well on your way to becoming a proficient object-oriented programmer.

Do you incorporate the CRA sequence?
Do you incorporate the CRA sequence?
CPA Approach Explained | Learn the Concrete, Pictorial, Abstract Method
CPA Approach Explained | Learn the Concrete, Pictorial, Abstract Method
Concrete vs Abstract Thinking: Difference and Comparison
Concrete vs Abstract Thinking: Difference and Comparison
The CPA Approach: What It Is & How to Use It In Primary Maths
The CPA Approach: What It Is & How to Use It In Primary Maths
Making it Tangible: Move from Concrete to Abstract
Making it Tangible: Move from Concrete to Abstract
An Approach that Works for Struggling Learners EVERY Time
An Approach that Works for Struggling Learners EVERY Time
Hands-On | Moving with Math - RTI Math Leader - C-R-A Instructional Model
Hands-On | Moving with Math - RTI Math Leader - C-R-A Instructional Model
How to Teach Math Effectively Using the Concrete Representational Abstract Model - Shelley Gray
How to Teach Math Effectively Using the Concrete Representational Abstract Model - Shelley Gray
How Using Concrete Examples When Working With Numbers Helps With More Abstract Use
How Using Concrete Examples When Working With Numbers Helps With More Abstract Use
Jen's Blog
Jen's Blog
How To Use Concrete, Pictorial and Abstract Resources in Maths - The Teaching Couple
How To Use Concrete, Pictorial and Abstract Resources in Maths - The Teaching Couple
Montessori Theory: The Key Concept of Concrete to Abstract
Montessori Theory: The Key Concept of Concrete to Abstract
two pieces of puzzles with the words concrete thinking and abstract thinking written below them
two pieces of puzzles with the words concrete thinking and abstract thinking written below them
the form evolution diagram shows different types of houses and how they are used to build them
the form evolution diagram shows different types of houses and how they are used to build them
How To Study Psychology Epistemology, Structuralist Psychology, How To Study Epistemology, Phenomenology Philosophical Terms, Epistemology Philosophy, Existential Psychology Diagram, Freud Psychoanalysis Notes, Existential Sociology Guide, Humanism Existentialism Study
How To Study Psychology Epistemology, Structuralist Psychology, How To Study Epistemology, Phenomenology Philosophical Terms, Epistemology Philosophy, Existential Psychology Diagram, Freud Psychoanalysis Notes, Existential Sociology Guide, Humanism Existentialism Study
Concrete and Abstract Thinking - What Are Those?
Concrete and Abstract Thinking - What Are Those?
an info sheet describing the different types of forms and their uses in architecture, including cubes
an info sheet describing the different types of forms and their uses in architecture, including cubes
The CRA Method for Dyscalculia: Concrete, Representational, Abstract
The CRA Method for Dyscalculia: Concrete, Representational, Abstract
Abstract vs, Concrete Goals
Abstract vs, Concrete Goals
What is the CRA Math Method? - The Math Spot
What is the CRA Math Method? - The Math Spot
AD