Home » Online Computer Education » Learn Fundamentals of Java Programming “Object Oriented Programming in Java Programming ” Lesson 17

Learn Fundamentals of Java Programming “Object Oriented Programming in Java Programming ” Lesson 17

Object Oriented Programming

By now you know quite a bit of Java programming. Now we begin to look at Java’s most fundamental feature – Classes and Objects. Java is an Object Oriented Programming (OOP) language. In an OOP language, a program is collection of objects that interact with other objects to solve a problem. Each object is an instance of a class.

Imagine you are creating a database application for a bookstore. You will need to store data about all the books in the store. So, each book will become an object in your program. Further, each book will have certain characteristics or attributes such as its Title, Author, Publisher, and Price. You may also want to perform certain actions on a book such as display its details on the computer screen or find its price. In an OOP language, such as Java, an entity such as a book in the example is referred to as a class. A class is a physical or logical entity that has certain attributes. The title, author, publisher, genre and price are the data members of the class Book. Displaying book details and getting its price are method members of the class Book. Method members can get, set or update the class data members.

Class Book
Data Members:
Method Members:

To describe one particular book in the library, you would create an object of the class book and fill in all its data members. For example one book in the library would be an object populated with the following data members:

Book: book1
Title: Game of Thrones
Author: George R Martin
Publisher: Harper Collins
Genre: Fiction
Price: 450
Another book would be another object populated with the following data members:
Book: book2
Title: Fundamentals of Database Systems
Author: Shamkant Navathe
Publisher: Pearson
Genre: Educational
Price: 400

You can think of a class as a template from which objects are created. All objects of the same class have the same type of data members.

Method members of a class are invoked on an object to perform the action associated with that method. For example, to display the details of book1 you would call the method member display() of the class with book1 as the invoking object. To display the details of book2 you would call the same method member display() but with the invoking object as book2.


The main objective of this website is to provide quality study material to all students (from 1st to 12th class of any board) irrespective of their background as our motto is “Education for Everyone”. It is also a very good platform for teachers who want to share their valuable knowledge.

Leave a Reply

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