Core java tutorial for beginners
A tutorial blog which explains different core concepts related to Java along with programming examples
Subscribe to Startertutorials.com's YouTube channel for different tutorial and lecture videos.

Categories: Object Orientation Concepts. 3 Comments on Object Orientation Concepts
4
(3)

This tutorial gives you knowledge of various object orientation concepts like object, class, message, object state and principles of object orientation.

 

What is the need to learn about object orientation concepts?

 

As you have already seen here: introduction to java, Java is an object oriented programming language. Java follows or is built upon the object oriented paradigm. Generally, every programming language supports at least one of the programming paradigms.

 

To understand a Java program and its structure, it is essential to know about the object orientation concepts.

 


Subscribe to our monthly newsletter. Get notified about latest articles, offers and contests.


Structured Paradigm Vs Object Oriented Paradigm

 

In programming languages following structured paradigm or procedural paradigm instructions are written in linear blocks or using functions. We can say that in procedural or structured paradigm, “Code allows access to data”. Examples of programming languages following procedural or structured paradigm can be found here.

 

In object oriented paradigm, the program is written using objects and classes. A problem can be solved through interactions between objects. We can say that in object oriented paradigm, “Data allows access to code”. Examples of object oriented languages can be found here.

 

Following table shows the difference between procedural/structured programming and object oriented programming:

 

Procedural Programming vs Object Oriented Programming

 

Object Oriented Paradigm

 

The fundamental unit in object oriented paradigm is an object. Let’s look at an object in detail.

 

oops features

 

Object

 

Object is a real world thing or entity that is tangible or intangible. An object consists of properties and/or behavior. For example consider a student object whose name is John. Student object contains properties or characteristics like name, age, gender, date of birth etc and behavior like eat, sleep, register, write exam etc.

 

A student object can be represented on paper or electronically as shown below. I am using the industry standard language UML (Unified Modeling Language) for representing the student object.

object notation oop

Class

 

It is common for most of the Java programs to have similar objects. Similar means objects having same properties and behavior. So, a class can be defined as a mold or template for creating objects. A class can also be defined as a collection of similar objects.

 

class oop

 

In the above example, the class is the mold (in yellow color) and the object is the paw (blue color). All the objects (blue color) will have the same size, shape etc.

 

Considering the above student example, let’s think of three student objects: John, Mary and Krishna. All of these three students will have similar properties like name, age, gender etc and similar behavior like register, write exam etc. These three objects can be grouped into a class named Student. A class can be represented diagrammatically (using UML) as shown below:

 

class symbol oop

 

Now we can represent the class Student and the three objects John, Mary and Krishna of the class Student as shown below:

 

class and objects

 

By now you will be able to distinguish between an object and a class. There is some more terminology you must know. Above, I said that object contains properties and behavior.

 

A property is a characteristic which can be used to describe the object and will generally be a noun. Behavior is defined as a set of operations that can be performed by the object or on the object. Operations are generally verbs.

 

Object state

 

The set of values assigned to the properties of an object is known as the state of an object. For example we know that for the John object there are three properties: name, age and gender. Then, the state of John object will be John, 21 and male which are the values of name, age and gender respectively.

 

Messages

 

In object oriented world objects don’t sit idle. They communicate with one other by passing messages. A message is a request to carry out a task. A task can be anything from displaying a message to retrieving data from database and process it.

 

An object can send messages to those objects only which can process the messages. For example, let’s think that an object Ken of Person class wants his dad (John) to purchase apples for him. To carry out that task Ken sends the message getApples(10) to John. This can be viewed diagrammatically as shown below:

message oop

 

It is the responsibility of John object to process the message getApples(10) and give response back to Ken object. The response message is not mandatory. In the above message getApples(10), 10 is a parameter.

 

A parameter is a mechanism to pass additional information along with the message. In the above example, 10 reflects the number of apples Ken wants.

 

Along with the above key concepts, there are key principles which act as the foundations in object oriented paradigm. Click this link to know about them: principles of object orientation.

How useful was this post?

Click on a star to rate it!

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?

Suryateja Pericherla

Suryateja Pericherla, at present is a Research Scholar (full-time Ph.D.) in the Dept. of Computer Science & Systems Engineering at Andhra University, Visakhapatnam. Previously worked as an Associate Professor in the Dept. of CSE at Vishnu Institute of Technology, India.

He has 11+ years of teaching experience and is an individual researcher whose research interests are Cloud Computing, Internet of Things, Computer Security, Network Security and Blockchain.

He is a member of professional societies like IEEE, ACM, CSI and ISCA. He published several research papers which are indexed by SCIE, WoS, Scopus, Springer and others.

Note: Do you have a question on this article or have a suggestion to make this article better? You can ask or suggest us by filling in the below form. After commenting, your comment will be held for moderation and will be published in 24-48 hrs.

3 Comments

You can follow any responses to this entry through the RSS 2.0 feed.

You have furnished the great information regarding Object Orientation that will be useful for me as well as for others. such a good explanation on you shared. good work & keep it up.

Great article!
I have been looking for similar information on internet as how many and which programming languages are available to learn. Here i have found a great article you have shared good details which beginner wants to know before starting career in programming. Thanks a lot for sharing!

Thank you very much for your effort which has given us a very good information..

Leave a Reply

Your email address will not be published. Required fields are marked *