Chapter 6: OOPS

 OOPS (Object-Oriented Programming Structure)

What the heck-. Why am I 'beginning' Java with such an abomination?
I know. It's unnecessary to teach OOPS at the beginning since we will be implementing these concepts later in the advanced Java journey. However, a 'programmer'  must know what OOPs is and why is it used.

Ok. Tell me what OOPS is.
OOPS! No no no, not the oops oops. We talkin' about programming here.
Basically, OOPS is a concept used in programming wherein the 'program structure' is relatable to real-life.
OOPS is established to bridge a connection between the real world and the program.  
Let's talk about the features of OOPS (what concepts are used to achieve an object oriented programming structure).

1. Objects
This might be a bit boring but I'll try to explain it in an interesting manner.
So every programming language which used OOPS, uses the concept of Objects. "What the heck are objects?" Long story short, an object. Yeah an object is an object. Just like in real life, let's say a car, a bike, fan, AC or just any object you observe around yourself has some characteristics, uses, function, appearance or something of that sort, say a Bike has a black colour, a cool headlight, low-seat, good engine, that are the features of the bike. 
        Now let's say you tell a computer about your bike. You tell it its colour, features, functions, logics, qualities etc. Once you're done, the computer understands that you have a bike with so colour...so functioning...so good...so expensive....
        So you have implemented the characteristics of a Bike in real life to a computer using programming. Great! So the way you have taught the computer about your bike...that is an object. 
        Therefore, an object may be defined as a unique entity which contains data(characteristics) and functions(behaviour) together in an OOP language.
        That's all you wanna know for now. OOP concepts will be understood more clearly as we progress through our path.

2. Classes
A class in java is similar to a class in real-life. Yeah, a class of students. In java, classes are the base that run the whole java program. 
Like in a classroom, it has students in it, and each students has various different features and behaviour.
Similarly, a class has different types of objects in it which have different features and behaviour.
    Therefore, a class may be defined as a group of similar type of objects with some characteristics(attributes) and behaviour(member function). 
    Since classes contain different type of objects, they are called an object factory.

3. Data Abstraction
Data Abstraction means hiding important data and information and displaying just what you want to display.
Hence, data abstraction may be defined as an act of representing essential features without knowing the background details.

4. Encapsulation
As discussed earlier, the whole java program including objects, functions etc. is made inside a class.
This act is known as encapsulation similar to a capsule (class) filled with medicine (function, objects).
Hence, Binding and wrapping of data and functions of a object into a single unit called class is called encapsulation.

5. Inheritance
Remember how there is a base unit called class in java which contains different functions and characteristics. Now what if we made another class and want it to inherit the properties of another class.
Just like inheritance in human genetics wherein genes(characteristics and properties) and passed from a parent to a child, in java a class (child class) can inherit properties of another class (parent class).

6. Polymorphism
The word polymorphism itself means existing in many(poly) forms(morph).
It means that a function in java may have many forms without changing its name, but only its function.
(Will be explained in detail later, for now just understand that there is a thing called function in java which performs functions defined by us).

Hence, polymorphism is the process of using single functions for more than one task. It allows the use of different internal structure(different functions) by keeping the same external interface. (same name)




OOPS Explanation By Oracle: Check The Resources Page!

THANKS FOR TUNING IN! Feel free to ask any queries in the comment section. Always there to help!

        


Comments

Popular posts from this blog

Chapter 10: Divide and Conquer

Chapter 1: Introduction To Java

Resources