Object Oriented Programming in Java

Hruturaj Kedar
Apr 11, 2021

--

Let’s consider a scenario where we want to build a building .To build this building we require a plant or a blueprint. So imagine building is an object. To build any object , Java virtual machine needs a structure and that blueprint is a class.

Imagine object as a dog. Every object has two things . object knows something and object does something.

The three steps of object declaration ,creation and assignment

1)Declare a reference variable

Dog myDog;

Tells the JVM to allocate space for a reference variable myDog;

2) Create an object

new Dog();

Tells the JVM to allocate space for new Dog object on heap.

3) Link the object and references

Dog myDog =new Dog( );

Assign the new Dog to reference variable myDog.

--

--

Hruturaj Kedar
Hruturaj Kedar

Written by Hruturaj Kedar

Hi, i am Hruturaj and am currently studying computer science from pune university.

No responses yet