Docsity

Object-Oriented Programming: Understanding Objects and Classes, Study notes of Computer Networks

Partial preview of the text

Download Object-Oriented Programming: Understanding Objects and Classes and more Study notes Computer Networks in PDF only on Docsity!

Java Programming

Topic: Object & Class Theory

ANIL SAROLIYA

Amity School of Engineering

B.Tech., CSE(5th^ Sem.)

Objects

 Following figure shows few entities and each of them can be treated as an object. So

we can say, an object can be a person, a place, or a thing with which the computer

must deal.

 So, objects mainly serve the following purposes:  Understanding of the real world problem and give the practical base for designers  Decomposition of a problem into modules. Such decomposition is depends on the judgment and nature of the problem

Classes

 The objects with the similar attributes and behavior (operations) are grouped into a Class.

or All those objects possessing similar properties are grouped into the same unit which is called as Class.

 The concept of class-ing the real world objects is logically shown in the following figure

Objects and Classes^4

Person Objects

Classes Cont..

A class is a template (pattern) that unites data and operations.

A class is an abstraction of the real world entities with similar properties.

A class identifies a set of similar objects.

Ideally, the class is an implementation of abstract data type.

In C++ or JAVA, related objects displaying the same behavior are grouped and represented by class in the following way:

Example (C++ Class) Example (Java Class) class account { private: char Name(20]; int AccountType; // data members int AccountNumber; float Balance; public: Deposit(); Withdraw(); // member functions Enquire(); };

public class Account { private String name; private int accountType; // data Members private int accountNumber; private float balance;

public int deposit(); public void withdraw(); //member functions public String enquire(); }

C++ Object Creation JAVA Object Creation account savings_account; account current_account; account FD_account;

Account savings_account = new Account(); Account current_account= new Account(); Account FD_account= new Account();

Thanks

Amity School of Engineering & Technology B.Tech., CSE(5th Sem.)