OOPs Introduction -Java

I am Developer, Artist and trying my luck on blogging as well. Well I am Ambitious, Passionate towards Learning, The Night Owl, And I Like challenges...
Search for a command to run...

I am Developer, Artist and trying my luck on blogging as well. Well I am Ambitious, Passionate towards Learning, The Night Owl, And I Like challenges...
No comments yet. Be the first to comment.
In this Series, We will learn about java from basic to advance and this series will help you to crack Java interviews and will also enhance your logic building and coding skills in java.
Post #2 in the Complete Prompt Engineering Series Welcome back! In What is Prompt Engineering? A Complete Introduction, you learned what prompt engineering is and why it matters. Now we're going deeper: understanding the engine under the hood. You do...

Welcome to the future of human-AI collaboration. If you're reading this in 2024-2025, you're witnessing a fundamental shift in how humans interact with machines—and prompt engineering is your passport to this new world. The Definition: What Exactly I...
In this post, we’ll walk through the anatomy of a great prompt, illustrate every step with vivid examples, and even peek under the hood to see what happens technically when you hit “send.” By the end, you’ll be able to craft prompts that unlock the f...

What is GenAI and Why Does Prompting Matter? If you’ve ever wondered how people interact with AI tools, or why some folks seem to get exactly what they want from tools like ChatGPT while others receive confusing or generic responses, this article is ...

Let’s be honest—being a developer isn’t just about writing code. It’s about solving problems, dealing with burnout, handling meetings, chasing deadlines, and finding time to learn, debug, and ship. But in the middle of this chaos, one simple habit ca...

OOPs is known as “Object Oriented Programming”.OOP is a Programming paradigm or a feature based on the concept of “Objects”. A programming paradigm means way of organizing a program. The two major programming paradigms are:
Before we move towards OOPs concepts Lets talk a bit about Structured Programming paradigm and it's disadvantages.

1. Sequence Execute a list of statements in order.
Example: Baking Bread Add flour. Add salt. Add yeast. Mix. Add water. Knead. Let rise. Bake.
2. Repetition Repeat a block of statements while a condition is true.
Example: Washing Dishes Stack dishes by sink. Fill sink with hot soapy water. While moreDishes Get dish from counter, Wash dish, Put dish in drain rack. End While Wipe off counter. Rinse out sink.
3. Selection Choose at most one action from several alternative conditions.
Example: Sorting Mail Get mail from mailbox. Put mail on table. While moreMailToSort Get piece of mail from table. If pieceIsPersonal Then Read it. ElseIf pieceIsMagazine Then Put in magazine rack. ElseIf pieceIsBill Then Pay it, ElseIf pieceIsJunkMail Then Throw in wastebasket. End If End While

Objects : In Structured Programming a problem is approached by dividing it into functions. Unlike this, in OOPs the problem is divided into objects. Thinking in terms of objects rather than functions make the designing of program easier. For example:
Classes : The class is one of the Basic concepts of OOPs which is a group of similar entities. t is only a logical component and not the physical entity. A class serves as a blueprint or a plan or a template. It specifies what data and what functions will be included in objects of that type. For example:
Inheritance : Inheritance is an important pillar of OOP(Object Oriented Programming). It is the mechanism in java by which one class is allow to inherit the features(fields and methods) of another class.
Let us discuss some of frequent used important terminologies:
Abstraction : Data Abstraction is the property by virtue of which only the essential details are displayed to the user. The trivial or the non-essentials units are not displayed to the user. Ex: A car is viewed as a car rather than its individual components. Data Abstraction may also be defined as the process of identifying only the required characteristics of an object ignoring the irrelevant details. The properties and behaviors of an object differentiate it from other objects of similar type and also help in classifying/grouping the objects. Consider a real-life example of a man driving a car. The man only knows that pressing the accelerators will increase the speed of car or applying brakes will stop the car but he does not know about how on pressing the accelerator the speed is actually increasing, he does not know about the inner mechanism of the car or the implementation of accelerator, brakes etc in the car. This is what abstraction is. In java, abstraction is achieved by interfaces and abstract classes. We can achieve 100% abstraction using interfaces.
Encapsulation : It is defined as the wrapping up of data under a single unit. It is the mechanism that binds together code and the data it manipulates. Another way to think about encapsulation is, it is a protective shield that prevents the data from being accessed by the code outside this shield.
It refers to the ability of OOPs programming languages to differentiate between entities with the same name efficiently. This is done by Java with the help of the signature and declaration of these entities.
Note: Polymorphism in Java are mainly of 2 types:
- Overloading
- Overriding