Java tutorial Part 1 - An OOP Language

in #java3 years ago

Object oriented programming (OOP) is at core of java. But java is not 100% Object oriented, which we will discuss later. But to major extent the OOP concept is integrated with java. So to understand java better let's discuss OOP concepts.
Lets understand the OOP concept one by one:-

  1. Object:- So what is an object? For starter object is anything physical or logical i.e a pen, a car, or a pc on which you are
    reading this article. Now lets get to technical term, an object is the instance of a class. it has an address and
    occupy space in RAM. An object has states and behaviors. In programming terminology these states are
    called attributes or variables and behaviors are called methods or functions.

  2. Class:- The collection of object is called class. It is logical identity, i.e it doesn't occupy space in RAM. It is a blue print
    on which a object is made, just like how houses are mode on the blueprints. These blueprints doesn't occupy
    space but houses made based on them does.

  3. Inheritance:- When an object acquire properties from the parent object similar to a child acquire characteristics from
    parent. there are various types of inheritance single, multiple(java does not support this), multilevel,
    hierarchical and hybrid inheritance. It increases reusability of code and provide run-time
    polymorphism.

  4. Polymorphism:- It means having more than one form. In Java, we use method overloading and method overriding to
    achieve polymorphism. We will understand it in detail later.

5)Abstraction:- Hiding internal details and showing functionality is known as abstraction. to understand it lets take
example of car. While driving car you doesn't think how turbine is rotating or how fuel injection working,
you just have visual of steering, brakes etc. Similarly in OOP we hide the complex details.

6)Encapsulation:- Binding (or wrapping) code and data together into a single unit are known as encapsulation. For
example you pack different books in your bag. It is the mechanism that binds together code and the
data and keep them safe from the outside world. It wraps the code and data so that it is not arbitrary
used by the outside code.

in Next part we will discuss about data types in java and variables.

Coin Marketplace

STEEM 0.17
TRX 0.13
JST 0.027
BTC 59099.74
ETH 2639.21
USDT 1.00
SBD 2.49