Object Oriented Technology

Share Embed Donate


Short Description

Object Oriented Technology...

Description

2

Biyani's Think Tank Concept based notes

Object Oriented Technology Using C++ (M.Sc I.T 2nd Sem)

Mr. Dhanesh Gupta Lecturer Deptt. of Information Technology Biyani Girls College, Jaipur

Object Oriented Technology using C++

3

Published by :

Think Tanks Biyani Group of Colleges

Concept & Copyright :

Biyani Shikshan Samiti Sector-3, Vidhyadhar Nagar, Jaipur-302 023 (Rajasthan) Ph : 0141-2338371, 2338591-95 Fax : 0141-2338007 E-mail : [email protected] Website :www.gurukpo.com; www.biyanicolleges.org

First Edition :

While every effort is taken to avoid errors or omissions in this Publication, any mistake or omission that may have crept in is not intentional. It may be taken note of that neither the publisher nor the author will be responsible for any damage or loss of any kind arising to anyone in any manner on account of such errors and omissions.

Leaser Type Setted by : Biyani College Printing Department

4

Preface

I

am glad to present this book, especially designed to serve the needs of

the students. The book has been written keeping in mind the general weakness in understanding the fundamental concepts of the topics. The book is selfexplanatory and adopts the “Teach Yourself” style. It is based on questionanswer pattern. The language of book is quite easy and understandable based on scientific approach. Any further improvement in the contents of the book by making corrections, omission and inclusion is keen to be achieved based on suggestions from the readers for which the author shall be obliged. I acknowledge special thanks to Mr. Rajeev Biyani, Chairman & Dr. Sanjay Biyani, Director (Acad.) Biyani Group of Colleges, who are the backbones and main concept provider and also have been constant source of motivation throughout this Endeavour. They played an active role in coordinating the various stages of this Endeavour and spearheaded the publishing work. I look forward to receiving valuable suggestions from professors of various educational institutions, other faculty members and students for improvement of the quality of the book. The reader may feel free to send in their comments and suggestions to the under mentioned address.

Author

Object Oriented Technology using C++

Syllabus M.Sc I.T 2nd Sem.

5

6

Content S.No.

Name of Topic

1.

Object-oriented Language

2.

Class and Object

3.

Polymorphism

4.

Pointers and File Handling

5.

Program

6

Keywords

7

Objective Questions

8

Bibliography

Page No.

Object Oriented Technology using C++

7

Chapter -1

Object-Oriented Programming Q.1. What is OOP? Explain Characteristics of an Object-oriented Language. Ans.: OOP stands for Object-Oriented Programming. Object oriented programming is combining the data and function in to a single unit , called object. The data of the object can be accessed by function associated with the object only . the function of one object can‟t access the data of other object. Characteristics of an Object-oriented Language. 1) Class Classes are the central feature of object-oriented programming and are often called user-defined types. A class is used to specify the form of an object and it combines data representation and methods for manipulating that data into one neat package. The data and functions within a class are called members of the class. 2) Object An object is an entity that has state, behavior and identity. A class provides the blueprints for objects, so basically an object is created from a class. We declare objects of a class with exactly the same sort of declaration that we declare variables of basic types. 3) Encapsulation Encapsulation is an Object Oriented Programming concept that binds together the data and functions that manipulate the data, and that keeps both safe from outside interference and misuse. Data encapsulation led to the important OOP concept of data hiding. 4) Data Abstraction Data abstraction refers to, providing only essential information to the outside word and hiding their background details ie. to represent the needed information in program without presenting the details. Data abstraction is a programming (and design) technique that relies on the separation of interface and implementation. Example of a TV which you can turn on and off, change the channel, adjust the volume, and add external components such as

8

speakers, VCRs, and DVD players BUT you do not know it's internal detail that is, you do not know how it receives signals over the air or through a cable, how it translates them, and finally displays them on the screen. Thus we can say, a television clearly separates its internal implementation from its external interface and you can play with its interfaces like the power button, channel changer, and volume control without having zero knowledge of its internals. 5)

Inheritance One of the most important concepts in object-oriented programming is that of inheritance. Inheritance allows us to define a class in terms of another class, which makes it easier to create and maintain an application. This also provides an opportunity to reuse the code functionality and fast implementation time. When creating a class, instead of writing completely new data members and member functions, the programmer can designate that the new class should inherit the members of an existing class. This existing class is called the base class, and the new class is referred to as the derived class.

6)

Polymorphism The word polymorphism is derived from two Greek words Poly which means many and morphos which means forms. So, polymorphism means the ability to take many forms. Polymorphism can be defined as the ability to use the same name for two or more related but technically different tasks. Overloading An overloaded declaration is a declaration that had been declared with the same name as a previously declared declaration in the same scope, except that both declarations have different arguments and obviously different definition (implementation). When we call an overloaded function or operator, the compiler determines the most appropriate definition to use by comparing the argument types you used to call the function or operator with the parameter types specified in the definitions. The process of selecting the

Object Oriented Technology using C++

9

most appropriate overloaded function or operator is called overload resolution. 7)

Dynamic Binding Binding refers to the linking of a function call to the code of function to be executed in response to the function call. Binding is of two types. Static or early binding Binding refers to the linking of a function call to the code of function to be executed in response to the function call is made at the compile time. Dynamic or late binding Dynamic Binding refers to linking a procedure call to the code that will be executed only at run time. The code associated with the procedure in not known until the program is executed, which is also known as late binding.

8)

Message passing Message Passing is nothing but sending and receiving of information by the objects. So this helps in building systems that simulate real life. Following are the basic steps in message passing. Creating classes that define objects and its behavior. Creating objects from class definitions Establishing communication among objects In OOPs, Message Passing involves specifying the name of objects, the name of the function, and the information to be sent.

Q2

What are the differences between procedural languages and object oriented languages?

Ans Procedure Programming

Oriented

Object Oriented Programming

Divided Into

In POP, program is divided into In OOP, program is divided small parts called functions. into parts called objects.

Importance

In POP,Importance is not given to data but to functions as well as sequence of actions to be done.

Approach

POP follows approach.

Access

POP does not have any access OOP

Top

In OOP, Importance is given to the data rather than procedures or functions because it works as a real world.

Down OOP follows approach. has

Bottom

access

Up

specifiers

10

Specifiers

specifier.

named Public, Protected, etc.

Private,

In POP, Data can move freely In OOP, objects can move and Data Moving from function to function in the communicate with each other system. through member functions. Expansion

To add new data and function OOP provides an easy way to in POP is not so easy. add new data and function.

Data Access

In OOP, data can not move In POP, Most function uses easily from function to Global data for sharing that can function,it can be kept public be accessed freely from function or private so we can control the to function in the system. access of data.

Data Hiding

POP does not have any proper OOP provides Data Hiding so way for hiding data so it is less provides more security. secure.

In OOP, overloading is In POP, Overloading is not possible in the form of Overloading possible. Function Overloading and Operator Overloading. Examples

Example of POP are : C, VB, Example of OOP are : C++, FORTRAN, Pascal. JAVA, VB.NET, C#.NET.

Q.3. What are advantages Object-oriented Language. Ans The major advantages of OOPs are: 1. Simplicity: Software objects model real world objects, so the complexity is reduced and the program structure is very clear. 2. Modularity: Each object forms a separate entity whose internal workings are decoupled from other parts of the system. 3. Modifiability: It is easy to make minor changes in the data representation or the procedures in an OO program. Changes inside a class do not affect any other part of a program, since the only public interface that the external world has to a class is through the use of methods. 4. Extensibility:

Object Oriented Technology using C++

11

Adding new features or responding to changing operating environments can be solved by introducing a few new objects and modifying some existing ones. 5. Maintainability: Objects can be maintained separately, making locating and fixing problems easier. 6. Re-usability: Objects can be reused in different programs. Q4 Ans

What is the basic structure of C++? Basic Structure of C++ program: #include directive Global Declarations return-type main() { Statements } Include Directive: The "#include" directive is used to include the files specified inside the "" brackets. Mostly standard files or header files of C++ are included using this directive like iostream.h, math.h etc. Global Declarations: The variables and other elements that need to be used all over the program or rather globally should be declared after the include directive. main() Function: The main function is executed first in a C++ program. If a main() is supposed to return a integer value then the return type should be specified as "int main()". If no value is returned simply use the return-type as "void". The statements used inside the "main()" function can include the functions, classes used in C++ along with other statements. For Example: #include void main() { cout
View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF