Click here to Get Complete Solved Assignments
List of Fresher Jobs, Walk in Interview
Right place for Job Seeker. Fresher Job, Walkin Interview, Exam results.

MC0066 – OOPS using C++ Q1. Distinguish between procedural language and OOP language. And explain the key features of OOP

Answer: The programming languages have evolved from machine languages, assembly languages to high level languages to the current age of programming tools. While machine level language and assembly language was difficult to learn for a layman, high level languages like C, Basic, Fortran and the like was easy to learn with more English like keywords. These languages were also known as procedural languages as each and every statement in the program had to be specified to instruct the computer to do a specific job. The procedural languages focused on organizing program statements into procedures or functions. Larger programs were either broken into functions or modules which had defined purpose and interface to other

Procedural approach for programming had several problems as the size of the software grew larger and larger. One of the main problems was data being completely forgotten. The emphasis was on the action and the data was only used in the entire process. Data in the program was created by variables and if more than one functions had to access data, global variables were used. The concept of global variables itself is a problem as it may be accidentally modified by an undesired function. This also leads to difficulty in debugging and modifying the program when several functions access a particular data.
The object oriented approach overcomes this problem by modeling data and functions together there by allowing only certain functions to access the required data.
The procedural languages had limitations of extensibility as there was limited support for creating user defined datatypes and defining how these datatypes will be handled. For example if the programmer had to define his own version of string and define how this new datatype will be manipulated, it would be difficult. The object oriented programming provides this flexibility through the concept of class.
Another limitation of the procedural languages is that the program model is not closer to real world objects. For example, if you want to develop a gaming application of car race, what data would you use and what functions you would require is difficult questions to answer in a procedural approach. The object oriented approach solves this further by conceptualizing the problem as group of objects which have their own specific data and functionality. In the car game example, we would create several objects such as player, car and traffic signal and so on. Some of the languages that use object oriented programming approach are C++, Java, Csharp, Smalltalk etc.
The key features of OOP languages are:
· Objects and Classes
An Object is a program representation of some real-world thing (i.e person, place or an event). Objects can have both attributes (data) and behaviors (functions or methods). Attributes describe the object with respect to certain parameters and Behavior or functions describe the functionality of the object.
According to Pressman, Objects can be any one of the following: a) External entities, b) Things, c) Occurrences or events, d) Roles, e) Organizational units, f) Places, g) Data Structures
For example, objects can be a menu or button in a graphic user interface program or it may be an employee in a payroll application. Objects can also represent a data structure such as a stack or a linked list. It may be a server or a client in a networking environment. Objects with the same data structure and behavior are grouped together as class. In other words, Objects are “instances” of a class. Classes are templates that provide definition to the objects of similar type. Objects are like variables created whenever necessary in the program. Classes and Objects support data encapsulation and data hiding which are key terms describing object oriented programming languages. Data and functions are said to be encapsulated in a single entity as object. The data is said to be hidden thus not allowing accidental modification.
· Inheritance
Inheritance is one of the most powerful features of Object Oriented Programming Languages that allows you to derive a class from an existing class and inherit all the characteristics and behavior of the parent class. This feature allows easy modification of existing code and also reuse of code. The ability to reuse components of a program is an important feature for any programming language.
· Polymorphism and Overloading
Operator overloading feature allows users to define how basic operators work with objects. The operator + will be adding two numbers when used with integer variables. However when used with user defined string class, + operator may concatenate two strings. Similarly same functions with same function name can perform different actions depending upon which object calls the function. This feature of C++ where same operators or functions behave differently depending upon what they are operating on is called as polymorphism (Same thing with different forms). Operator overloading is a kind of polymorphism.


Post a Comment

Related Posts Plugin for WordPress, Blogger...

Get Our Latest Posts Via Email - It's Free

Enter your email address:

Delivered by FeedBurner