Sie sind auf Seite 1von 7

Amity School of Engineering

B.Tech., CSE(5th Sem.) & ECE(3rd Sem.)

Java Programming Topic: Object & Class Theory ANIL SAROLIYA

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
2

Objects Contd...
Every object will have data structures called attributes and behavior called operations. The different notations of an object which uniting both the data and operations, are shown in following figure:

Different styles of representing an object

or

or

EXAMPLE

Different styles of representing the account object

or

or

Classes
The objects with the same data structure (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
Person Objects

Objects and Classes

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)


class account { private: char Name(20]; int AccountType; // data members int AccountNumber; float Balance; public: Deposit(); Withdraw(); // member functions Enquire(); }; C++ Object Creation account savings_account; account current_account; account FD_account;

Example (Java Class)


public class Account { private String name; private int accountType; // data Members private int accountNumber; private float balance; public int deposit(); public void withdraw(); public sting enquire();

//member functions

}
JAVA Object Creation Account savings_account = new Account(); Account current_account= new Account(); Account FD_account= new Account();

Advantages & Disadvantages of OOPs


MERITS
Supports Following:
Encapsulation Data Abstraction Inheritance Polymorphism

DEMERITS
Compiler overhead Runtime overhead Re-orientation of software developer to object-oriented thinking Requires the mastery over the following areas:
Software Engineering Programming Methodologies

Related to Real world entity

Benefits only in long run while managing large software projects

Amity School of Engineering B.Tech., CSE(5th Sem.) & ECE(3rd Sem.)

Thanks
7

Das könnte Ihnen auch gefallen