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. …

Constructor in Java 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 …

Polymorphism in Java 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 …

this Keyword in Java 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 …

Introduction to Object Oriented Programming Concepts in Java Read More »