By yourself some time

We all have limited time. Anything that saves us time coding, and improves the readability of our code is wonderful. Readability is key, as we read code much more than we write it. Many people may…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Object Oriented Programming

Object Oriented Programming is a programming style, which is associated with the concept like Class, Object, Inheritance, Encapsulation, Abstraction, Polymorphism.

CLASS: A class is a collection of method and variables. Object Oriented Programming, A class is a blueprint for creating objects (a particular data structure), providing initial values for state (member variables or attributes), and implementations of behavior (member functions or methods). The user-defined objects are created using the class keyword.

OBJECT: An object is an instance of a class. Object Oriented Programming which revolve around the real life entities. Objects in a program can represent real world things or abstractions e.g. automobiles, houses and employees.

INHERITANCE: It is one of the key features of Object Oriented Programming. Inheritance provided mechanism that allowed a class to inherit property of another class. when a class extends another class it inherits all non-private member including fields and methods. The class which inherits the properties of other is known as subclass(derived class, child class) and the class whose properties are inherited is known as super class (base class, parent class). Inheritance defines is -a relationship between a super class and its sub class. extends and implements keywords are used to describe inheritance in java. It use for code Reusability.

eg:

public class Person{

private String name;

public Person(){

name = “No name yet”;

}

public Person(String initialName){

name = initialName;

}

public void setName(String newName){

name = newName;

}

public String getName(){

return name;

}

public void writeOutput(){

System.out.println(“Name: “ + name);

}

}

Using Super

Whenever a subclass needs to refer to its immediate super class, it can do so by use of the keyword super. super has two general forms: The first calls the super class constructor. The second is used to access a member of the super class that has been hidden by a member of a subclass.

ENCAPSULATION: Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the idea of bundling data and methods that work on that data within one unit, eg: a class in Java. This concept is also often used to hide the internal representation, or state, of an object from the outside.

ABSTRACTION: Abstraction is a process of hiding the implementation details and showing only functionality to the user. Another way, it shows only important things to the user and hides the internal details . For example sending sms, we just type the text and send the message. we don’t know the internal processing about the message delivery.

POLYMORPHISM: It is the ability to appear in many forms. In object-oriented programming, polymorphism refers to a programming language’s ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes.

Add a comment

Related posts:

A motivational tip

Anger puts one on the path of destruction more than danger itself.. “A motivational tip” is published by The Writer.

How to Analyze Airbnb Performance Data in the Right Way

Exploring and Understanding Airbnb, its popularity, host listings and its future trends for the City of New York

Evolution of a Roadmap

How often do you re-align your goals and visions with that of your product and how do you do it? All you need is a Roadmap which you can refer to from time to time and make the necessary changes…