Category Archives: Java OOP

Constructor in Java

Constructor is a special method which is used to initialize the state of an object. Constructor is special method because it has following properties: – Automatically called – Constructor name is same as class name – No return type Programmer can’t call constructor explicitly. It is called automatically at the time of creation of object.… Read More »

Polymorphism in Java

Polymorphism is used to assume the ability of several different forms. Or we can say performing one task in different ways. In java + operator is used for addition as well to concatenate (join) strings. Here a single operator is doing two different things depending upon the type of argument, so it is the situation… Read More »

this Keyword in Java

this holds the reference of current object. Observe below example: class demo {                 int  x=10;                 void show(int x,demo d1)                 {                                 System.out.println(this.x);                                 System.out.println(d1.x);                                 System.out.println(x);                 }                 public static void main(String…s)                 {                                 demo d1=new demo();                                 d1.show(20,d1);                 } } Output: 10 10 20 In Java by default… Read More »

Classes and Objects in Java

Class Class is the collection of similar type of objects which have some common properties. Class is a concept which is implemented by object. Class is a blueprint of java program from which we create object, then object is instance of class. We can also say that class is a collection of variables and methods.… Read More »

Introduction to Object Oriented Programming Concepts in Java

Object Oriented Programming is used to represent the real world data. The main focus is on data. Simula is considered to be the first object oriented programming language. Object Oriented Programming Concepts There are 6 object oriented programming concepts in Java which are given below. Class Object Encapsulation Polymorphism Inheritance Abstraction Class Class is a… Read More »