Introducing Object Oriented Programming
page 3 of 5
by Joydip Kanjilal
Feedback
Average Rating: 
Views (Total / Last 10 Days): 24044/ 61

Object Oriented Programming Terminologies

Object Oriented Programming (OOP) emphasizes the following concepts

Class

A class may be defined as a self contained unit that encapsulates a collection of data and methods that operate on the data.  Basically there are three access modifiers that are used in a class.  They are public, private and protected.  A public member is both accessible and inheritable.

A private member cannot be accessed from the outside world; nor can it be inherited.  A protected member is inheritable, but cannot be accessed from outside of the class hierarchy.  We can say that a protected member is an inheritable private member.

Object

An object may be defined as an instance of a class that can send and receive messages and process data.  The software objects are used to model the real-world objects that are common in every day life.  Real-world objects share two characteristics:

·         State

·         Behavior

Method

A method is a way of operating on an object.  A method can have either the private, public or protected visibility label.  The visibility label of a member of the class indicates how much of the class is exposed to the outside world.

Inheritance

This is a feature by virtue of which a child class inherits its parent.  A subclass inherits all the members of its base, except those that are private.  A sub class may have one or more base classes, i.e. it can be inherited from one or more bases.  Such type of inheritance is known as Multiple Inheritance.  A sub class can also extend the behavior of its inherited members and add new members.  Here it needs to be mentioned that there are two relationships in OOPS- "has-a" and "is-a."  The former indicates a composition, while the later indicates inheritance.  Inheritance offers the following benefits:

·         Reusability

·         Implement Abstract Data Types

Encapsulation

Encapsulation is a property of OOPS that combines the data and the members of a class inside a unit resulting in an isolation of the unit from the external world.  It exposes only the functional details, but hides the implementation details of the class.

The benefits of encapsulation:

·         Modularity

·         Information-hiding

Abstraction

Abstraction is the ability of a program to ignore the details of an object's (sub)class and work at a more generic level when appropriate.  Abstraction is a concept or idea that is not related to any particular instance.  It is the process of identifying common patterns that can have systematic variations.  The purpose of an Abstract class is to provide a common definition that the subclasses can share.

Polymorphism

Polymorphism is behavior that varies depending on the class in which the behavior is invoked.  In other words, two or more classes can react differently to the same message.  Polymorphism is the ability of the objects to react differently when presented with different information, known as parameters.  In a functional programming language the only way to complete two different tasks is to have two functions with different names.  Object-oriented languages, which include Java, allow different methods to be run depending on what types of parameters are specified.  The word Polymorphism is derived from two Greek words, namely Poly and Morphos.  Poly indicates many and Morphos indicates forms.  Therefore, it is the existence of the same thing in different forms.

 

Polymorphism can be of the following types.

·         Static or Compile Time Polymorphism

·         Dynamic or Runtime Polymorphism

Static Polymorphism is the polymorphism that occurs at compile time.  In static polymorphism the binding or that association of an object of a class and its member occurs at compile time. Overloaded constructors of a class and polymorphic non-virtual methods are classic examples of Static or Compile Time Polymorphism.  Dynamic Polymorphism refers to the polymorphism that occurs at run time.  It is achieved using Virtual Methods.  In dynamic polymorphism the binding or that association of an object of a class and its member occurs at run time.

Instantiation

Instantiation is the ability of a non-abstract class to create a finite number of objects.  An instance of a class is commonly known as an object.

Sealed and Final Classes

A sealed class in C# or a final class in Java is one that can be instantiated, but not inherited.

Message

Objects can interact and communicate with each other in the same or across different systems using messages.  A message is comprised of the addressee, the method name and the parameters.  When an object wants to invoke a method on another object, it sends the later a message.

Interface

In general, an interface is a device or a system that unrelated entities use to interact.  According to this definition, a remote control is an interface between you and a television set, the English language is an interface between two people, and the protocol of behavior enforced in the military is the interface between individuals of different ranks.  You use an interface to define a protocol of behavior that can be implemented by any class anywhere in the class hierarchy.


View Entire Article

User Comments

Title: Comment on this article   
Name: Snigdha
Date: 2006-09-07 8:52:06 AM
Comment:
Excellent ,it covers so many things using few words
Title: Nice Job   
Name: Sandeep
Date: 2006-07-21 1:39:57 AM
Comment:
It's a nice article for those who were preparing for Interviews.Thank You
Sandeep

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2023 ASPAlliance.com  |  Page Processed at 2023-04-01 7:44:35 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search