Understanding OOPs and Abstraction using Real World Scenario
Last Updated :
19 May, 2020
Object-oriented programming: As the name suggests,
Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming. In this article, we will discuss how this OOP's concept is implemented in real world scenario.
Let's consider an example of a Geek who wants to learn the
Java full course online. He chooses one of the sources to know about various platforms which are offering Java Course. Let's say he chooses Google and he searches for the course. Once Google accepts the request, it will perform various actions to carry out the request until the request has been served. The following illustration demonstrates the steps performed:

Below is the implementation of the demo class which demonstrates the steps mentioned in the above image:
Java
// Java Program to demonstrate
// the above steps
// Here, Geek is a class
class Geek {
// Until no request the
// value will be false
boolean value = false;
private String request = "";
// Constructor of Geek
Geek(String request)
{
// The value becomes true
// once the constructor called
// or when the object created
value = true;
this.request = request;
System.out.println(
"Geek Requested: "
+ request);
}
public String getRequest()
{
return this.request;
}
}
// A google class
class Google {
private String request;
// Constructor of Google
Google(String request)
{
this.request = request;
System.out.println(
"Google Searched: "
+ request);
}
// This class may also contains methods
// through which the request passes
// messages to further more objects
// and also send back a response
}
// Demo class to understand
// A way of using abstraction
public class MainDemo2 {
// Driver code
public static void main(String[] args)
{
// Geek class object creation
Geek g = new Geek("Java");
// Checking whether Geek
// has requested or not
if (g.value) {
// If the Geek requested
// Google object created
Google gl = new Google(g.getRequest());
// Google performs some action
// To satisfy the Geek with his
// Desired result
}
}
}
Output:
Geek Requested: Java
Google Searched: Java
An illustrative figure of the above program:

From the above example, lets understand the different terminology used in the
Object-Oriented Design:
- Agents and Community:
- Agent: Every object in the community acts as an agent (i.e.) from the above example, we can say that Geek, Google, and the other extra objects are known to be agents. Every agent performs some actions and those actions are being utilized by other members of the community to solve the problem.
- Community: It is created by actions. In the above example, we can say that the search engine community has been formed.
Therefore, in the above example:
Agents: Geek, Google, and other objects
Community: Search engine community
- Messages and Methods:
- Messages: Every message may be a request or response that is being passed to other members of the community.
- Methods Every method is used to perform an action in the community, that action will be used by other members of the community to solve various problems.
- Responsibilities: From the above example, we can observe that once the Geek passes a request to Google, it will accept the request and it performs various actions to give him the desired result. It means if the request accepted by an agent, it is the responsibility of the agent to carry out the request until the problem is solved.
Finally, we can conclude that we have achieved hiding of the data or
Abstraction by implementing the system in such a way that when the Geek passes the request, the actions performed by Google are hidden from him to get the desired result.
Similar Reads
Difference Between Data Hiding and Abstraction in Java Abstraction Is hiding the internal implementation and just highlight the set of services. It is achieved by using the abstract class and interfaces and further implementing the same. Only necessarily characteristics of an object that differentiates it from all other objects. Only the important detai
6 min read
Understanding Encapsulation, Inheritance, Polymorphism, Abstraction in OOPs As the name suggests, Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism etc in programming. The main aim of OOP is to bind together the data and the functio
6 min read
Spring - Understanding Inversion of Control with Example Spring IoC (Inversion of Control) Container is the core of the Spring Framework. It creates objects (beans), configures them, injects dependencies, and manages their life cycles. The container uses Dependency Injection (DI) to manage application components. It retrieves object configuration from XML
7 min read
Messages, aggregation and abstract classes in OOPS Object-Oriented Programming System (OOPS) is the basic concept of many programming languages. It is a paradigm based on the object which contains methods and data. This concept is used to make programming a class and object model which behaves like a real-world scenario. In this article, we'll learn
5 min read
Abstraction by Parameterization and Specification in Java Abstraction by Parameterization and specification both are important methods in Java. We do this in hope of simplifying our analysis by separating attributes and details implementation for user requirements by showing the essential part to the user and hiding certain details for various purposes lik
4 min read
Understanding Classes and Objects in Java The term Object-Oriented explains the concept of organizing the software as a combination of different types of objects that incorporate both data and behavior. Hence, Object-oriented programming(OOPs) is a programming model, that simplifies software development and maintenance by providing some rul
10 min read