Solution Set. 1. Attempt any three of the following: 15 a. What is object oriented programming? State its applications.
|
|
- Kimberly French
- 5 years ago
- Views:
Transcription
1 (2½ Hours) [Total Marks: 75] Subject: OOPs with C++ Solution Set 1. Attempt any three of the following: 15 a. What is object oriented programming? State its applications. Ans: Object-oriented programming (OOP) is a software programming modelconstructed around objects. This model compartmentalizes data into objects (data fields) and describes object contents and behavior through the declaration of classes (methods). Object-oriented programming allows for simplified programming. Its benefits include reusability, refactoring, extensibility, maintenance and efficiency. Applications: Real-time system Simulation and modeling Object-oriented data bases Hypertext, Hypermedia, and expertext AI and expert systems Neural networks and parallel programming Decision support and office automation systems CIM/CAM/CAD systems b. Illustrate the relationship between object and class. Ans: objects contain data, and code to manipulate that data. The entire set of data and code of an object can be made a user-defined data type with the help of class. Each object is associated with the data of type class with which they are created. A class is thus a collection of objects similar types. For examples, Mango, Apple and orange members of class fruit. c. Explain the concept of abstraction with suitable example. Ans: Abstraction refers to the act of representing essential features without including the background details or explanation. Classes use the concept of abstraction and are defined as a list of abstract attributes such as size, wait, and cost, and function operate on these attributes. They encapsulate all the essential properties of the object that are to be created. The attributes are sometime called data members because they hold information. The functions that operate on these data are sometimes called methods or member function. d. Explain in brief about reusability with suitable example. Ans: Inheritance ( Reusability) is the process by which objects of one class acquired the properties of objects of another classes. It supports the concept of hierarchical classification. For example, the bird, robin is a part of class flying bird which is again a part of the class bird. e. What is polymorphism? Give suitable example for the same. Ans: Polymorphism means the ability to take more than on form. An operation may exhibit different behavior is different instances. The behavior depends upon the types of data used in the operation. For example, consider the operation of addition. For two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by concatenation. The process of making an operator to exhibit different behaviors in different instances is known as operator
2 overloading. f. Write a note on dynamic binding. Ans: Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run time. It is associated with polymorphism and inheritance. A function call associated with a polymorphic reference depends on the dynamic type of that reference. 2. Attempt any three of the following: 15 a. Explain the structure of C++ class. Ans: Class MyClass private: datatype var; public: void Method1() Define Method // ; void main() MyClassobj; Obj.Method1(); b. Write a C++ program to create a class Bank with acno, custname, bal as its attributes. And implement the methods withdraw(), deposit() and showbalance(). Class Bank private: intaccno; char custname[40];double bal; public: void withdraw() Define Method // void deposit() Define Method // void showbalance() Define Method // ; void main() Bank obj; obj.withdraw(); obj.deposit(); obj.showbalance(); c. Explain in brief the concept of friend function and class with suitable example. lass Box double width; public: friend void printwidth( Box box ); void setwidth( double wid ); ; // Member function definition
3 void Box::setWidth( double wid ) width = wid; // Note: printwidth() is not a member function of any class. void printwidth( Box box ) /* Because printwidth() is a friend of Box, it can directly access any member of this class */ cout<< "Width of box : " <<box.width<<endl; // Main function for the program int main() Box box; // set box width without member function box.setwidth(10.0); // Use friend function to print the wdith. printwidth( box ); return 0; d. What is constructor? State its characteristics. A constructor (having the same name as that of the class) is a member function which is automatically used to initialize the objects of the class type with legal initial values. These have some special characteristics. These are given below: (i) These are called automatically when the objects are created. (ii) All objects of the class having a constructor are initialized before some use. (iii) These should be declared in the public section for availability to all the functions. (iv) Return type (not even void) cannot be specified for constructors. (v) These cannot be inherited, but a derived class can call the base class constructor. (vi) These cannot be static. (vii) Default and copy constructors are generated by the compiler wherever required. Generated constructors are public. (viii) These can have default arguments as other C++ functions. (ix) A constructor can call member functions of its class. (x) An object of a class with a constructor cannot be used as a member of a union. (xi) A constructor can call member functions of its class. (xii) We can use a constructor to create new objects of its class type by using the syntax e. Write a C++ program to implement the concept of constructor and destructor. class add private : int num1,num2,num3; public : add(int=0, int=0); //default argument constructor //to reduce the number of constructors
4 void sum(); void display(); ~ add(void); //Destructor ; Add:: ~add(void) Num1=num2=num3=0; Cout<< \nafter the final execution, me, the object has entered in the << \ndestructor to destroy myself\n ; //Constructor definition add() Add::add(int n1,int n2) num1=n1; num2=n2; num3=0; //function definition sum () Void add::sum() num3=num1+num2; //function definition display () Void add::display () cout<< \nthe sum of two numbers is <<num3<<end1; void main() Add obj1,obj2(5),obj3(10,20): Obj1.sum(); //function call Obj2.sum(); Obj3.sum(); cout<< \nusing obj1 \n ; obj1.display(); //function call cout<< \nusing obj2 \n ; obj2.display(); cout<< \nusing obj3 \n ; obj3.display(); f. Explain the concept of pointer to object with suitable example. Ans: A variable that holds an address value is called a pointer variable or simply pointer. Pointer can point to objects as well as to simple data types and arrays. sometimes we dont know, at the time that we write the program, how many objects we want to create. when this is the case we can use new to creat objects while the program is running. new returns a pointer to an unnamed objects. class student private: introllno; string name;
5 public: student():rollno(0),name("") student(int r, string n): rollno(r),name (n) void get() cout<<"enter roll no"; cin>>rollno; cout<<"enter name"; cin>>name; void print() cout<<"roll no is "<<rollno; cout<<"name is "<<name; ; void main () student *ps=new student; (*ps).get(); (*ps).print(); delete ps; 3. Attempt any three of the following: 15 a. Explain the concept of function overloading with suitable example. long add(long, long); float add(float, float); int main() long a, b, x; float c, d, y; cout<< "Enter two integers\n"; cin>> a >> b; x = add(a, b); cout<< "Sum of integers: " << x <<endl; cout<< "Enter two floating point numbers\n"; cin>> c >> d; y = add(c, d); cout<< "Sum of floats: " << y <<endl;
6 return 0; long add(long x, long y) long sum; sum = x + y; return sum; float add(float x, float y) float sum; sum = x + y; return sum; b. Write a C++ program to overload binary (++) operator. Ans: #include<iostream> usingnamespacestd; classbox double length;// Length of a box double breadth;// Breadth of a box double height;// Height of a box public: doublegetvolume(void) return length * breadth * height; voidsetlength(doublelen) length =len; voidsetbreadth(doublebre) breadth =bre; voidsetheight(doublehei) height =hei; // Overload + operator to add two Box objects.
7 Boxoperator+(constBox& b) Boxbox; box.length=this->length +b.length; box.breadth=this->breadth +b.breadth; box.height=this->height +b.height; return box; ; // Main function for the program int main() BoxBox1;// Declare Box1 of type Box BoxBox2;// Declare Box2 of type Box BoxBox3;// Declare Box3 of type Box double volume =0.0;// Store the volume of a box here // box 1 specification Box1.setLength(6.0); Box1.setBreadth(7.0); Box1.setHeight(5.0); // box 2 specification Box2.setLength(12.0); Box2.setBreadth(13.0); Box2.setHeight(10.0); // volume of box 1 volume =Box1.getVolume(); cout<<"volume of Box1 : "<< volume <<endl; // volume of box 2 volume =Box2.getVolume(); cout<<"volume of Box2 : "<< volume <<endl; // Add two object as follows: Box3=Box1+Box2; // volume of box 3 volume =Box3.getVolume(); cout<<"volume of Box3 : "<< volume <<endl; return0; c. List the operators that cannot be overloaded. Explain the rules for overloading the operators. Ans: Operators that cannot be overloaded:::,.*,.,?: Rules: 1. Only existing operators can be overloaded. New operators cannot be overloaded.
8 2. The overloaded operator must have at least one operand that is of user defined type. 3. We cannot change the basic meaning of an operator. That is to say, We cannot redefine the plus(+) operator to subtract one value from the other. 4. Overloaded operators follow the syntax rules of the original operators. They cannot be overridden. 5. There are some operators that cannot be overloaded like size of operator(sizeof), membership operator(.), pointer to member operator(.*), scope resolution operator(::), conditional operators(?:) etc 6. We cannot use friend functions to overload certain operators.however, member function can be used to overload them. Friend Functions can not be used with assignment operator(=), function call operator(()), subscripting operator([]), class member access operator(->) etc. 7. Unary operators, overloaded by means of a member function, take no explicit arguments and return no explicit values, but, those overloaded by means of a friend function, take one reference argument (the object of the relevent class). 8. Binary operators overloaded through a member function take one explicit argument and those which are overloaded through a friend function take two explicit arguments. 9. When using binary operators overloaded through a member function, the left hand operand must be an object of the relevant class. 10. Binary arithmetic operators such as +,-,* and / must explicitly return a value. They must not attempt to change their own arguments. d. What is static function? Explain how it is implemented. Ans: When we declare a member of a class as static it means no matter how many objects of the class are created, there is only one copy of the static member. A static member is shared by all objects of the class. All static data is initialized to zero when the first object is created, if no other initialization is present. We can't put it in the class definition but it can be initialized outside the class as done in the following example by redeclaring the static variable, using the scope resolution operator :: to identify which class it belongs to. ( You can assume any program) classbox public: staticintobjectcount; // Constructor definition Box(double l =2.0,double b =2.0,double h =2.0) cout<<"constructor called."<<endl; length = l;
9 breadth = b; height = h; // Increase every time object is created objectcount++; doublevolume() return length * breadth * height; staticintgetcount() returnobjectcount; private: double length;// Length of a box double breadth;// Breadth of a box double height;// Height of a box ; // Initialize static member of class Box intbox::objectcount=0; int main(void) // Print total number of objects before creating object. cout<<"inital Stage Count: "<<Box::getCount()<<endl; BoxBox1(3.3,1.2,1.5);// Declare box1 BoxBox2(8.5,6.0,2.0);// Declare box2 // Print total number of objects after creating object. cout<<"final Stage Count: "<<Box::getCount()<<endl; return0; e. What is pure virtual function? Explain how it is implemented. Ans: Pure virtual Functions are virtual functions with no definition. They start with virtual keyword and ends with = 0. Here is the syntax for a pure virtual function, virtual void f() = 0; class Base //Abstract base class public: virtual void show() = 0; //Pure Virtual Function ; class Derived:public Base public: void show() cout<< "Implementation of Virtual Function in Derived class"; ;
10 int main() Base obj; Base *b; Derived d; b = &d; b->show(); //Compile Time Error Pure Virtual functions can be given a small definition in the Abstract class, which you want all the derived classes to have. Still you cannot create object of Abstract class. Also, the Pure Virtual function must be defined outside the class definition. If you will define it inside the class definition, complier will give an error. Inline pure virtual definition is Illegal. f. Explain in brief the concept of abstract class. Ans: Abstract Class is a class which contains atleast one Pure Virtual function in it. Abstract classes are used to provide an Interface for its sub classes. Classes inheriting an Abstract Class must provide definition to the pure virtual function, otherwise they will also become abstract class. Characteristics of Abstract Class 1. Abstract class cannot be instantiated, but pointers and refrences of Abstract class type can be created. 2. Abstract class can have normal functions and variables along with a pure virtual function. 3. Abstract classes are mainly used for Upcasting, so that its derived classes can use its interface. 4. Classes inheriting an Abstract Class must implement all pure virtual functions, or else they will become Abstract too. 4. Attempt any three of the following: 15 a. Explain the concept of multilevel inheritances with suitable example. Ans: In this type of inheritance the derived class inherits from a class, which in turn inherits from some other class. The Super class for one, is sub class for the other.
11 b. Write a C++ program to implement the following hierarchy of inheritance. Lion Tiger Animal Ans: Class Lion ; Class Tiger ; Class Animal : public Lion, Tiger ; c. Explain the concept of method overriding with suitable example. C++ Function Overriding. If derived class defines same function as defined in its base class, it is known as function overriding in C++. It is used to achieve runtime polymorphism. It enables you to provide specific implementation of the function which is already provided by its base class. d. Write a note on containership. When a class contains objects of another class or its members, this kind of relationship is called containership or nesting and the class which contains objects of another class as its members is called as container class. Class class_name1
12 ; Class class_name2 ; Class class_name3 Class_name1 obj1; Class_name2 obj2; - ; // object of class_name1 // object of class_name2 e. Explain the mechanism of handling the exception with suitable example. Ans: An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such as an attempt to divide by zero. try // protected code catch( ExceptionName e1 ) // catch block catch( ExceptionName e2 ) // catch block catch( ExceptionNameeN ) // catch block f. Explain in brief about hybrid inheritance with suitable example. Ans: Hybrid Inheritance is combination of Hierarchical and Multilevel Inheritance. 5. Attempt any three of the following: 15
13 a. Explain the concept of function template with suitable example. Ans: Function Template The general form of a template function definition is shown here template <class type> ret-type func-name(parameter list) // body of function #include <iostream> #include <string> using namespace std; template <typename T> inline T const& Max (T const& a, T const& b) return a < b? b:a; int main () inti = 39; int j = 20; cout<< "Max(i, j): " << Max(i, j) <<endl; double f1 = 13.5; double f2 = 20.7; cout<< "Max(f1, f2): " << Max(f1, f2) <<endl; string s1 = "Hello"; string s2 = "World"; cout<< "Max(s1, s2): " << Max(s1, s2) <<endl; return 0; b. Write a C++ program to implement the concept of class template. Ans: #include <iostream> #include <vector> #include <cstdlib> #include <string> #include <stdexcept> using namespace std; template <class T> class Stack private: vector<t>elems; // elements
14 public: void push(t const&); // push element void pop(); // pop element T top() const; // return top element bool empty() const // return true if empty. return elems.empty(); ; template <class T> void Stack<T>::push (T const&elem) // append copy of passed element elems.push_back(elem); template <class T> void Stack<T>::pop () if (elems.empty()) throw out_of_range("stack<>::pop(): empty stack"); // remove last element elems.pop_back(); template <class T> T Stack<T>::top () const if (elems.empty()) throw out_of_range("stack<>::top(): empty stack"); // return copy of last element return elems.back(); int main() try Stack<int>intStack; // stack of ints Stack<string>stringStack; // stack of strings // manipulate int stack intstack.push(7); cout<<intstack.top() <<endl; // manipulate string stack stringstack.push("hello"); cout<<stringstack.top() <<std::endl; stringstack.pop(); stringstack.pop();
15 catch (exception const& ex) cerr<< "Exception: " <<ex.what() <<endl; return -1; c. State and explain different file modes. Ans: The mode parameter specifies the mode in which the file has to be opened. d. Write a C++ program to read the input from the user and write into the file. [Select a suitable file mode] #include <fstream> #include <iostream> #include <string> usingnamespacestd; int main() string sentence; string mysent; //Creates an instance of ofstream, and opens example.txt ofstreama_file ( "example.txt", ios::app ); cin>>mysent; // Outputs to example.txt through a_file a_file<<mysent<< "\n"; // Close the file stream explicitly a_file.close(); //Opens for reading the file ifstreamb_file ( "example.txt" ); //Reads one string from the file b_file>>mysent; cout<< "Please Write the sentence:" <<"\n"; cin>> sentence; if (sentence == mysent) cout<< "you did it right!" << "\n";
16 else cout<< "No!" <<endl; system("pause"); // wait for a keypress // b_file is closed here e. Write a C++ program to display the contents from the file in a console mode. [Select a suitable file mode] #include <stdio.h> #include <stdlib.h> // For exit() intmain() FILE*fptr; charfilename[100], c; printf("enter the filename to open \n"); scanf("%s", filename); // Open file fptr = fopen(filename, "r"); if(fptr == NULL) printf("cannot open file \n"); exit(0); // Read contents from file c = fgetc(fptr); while(c!= EOF) printf("%c", c); c = fgetc(fptr); fclose(fptr); return0; f. Write a C++ program to copy the contents from one file to other file. [Select a suitable file mode] #include<iostream.h> #include<conio.h> #include<fstream.h> void main() ofstreamfout;
17 ifstream fin; inti=0; int n; char ch[20]; clrscr(); fout.open("a.txt"); cout<<"enter no. of lines"; cin>>n; cout<<"\nenter contents to first file\n\n"; do cin.getline(ch,20); fout<<ch; fout<<"\n"; i++; while(i<=n); fout.close(); fin.open("a.txt"); fout.open("a.txt"); cout<<"\ncontents of second file\n"; while(fin.eof()==0) fin.getline(ch,20); fout<<ch; fout<<"\n"; fout.close(); fin.close(); fin.open("a1.txt"); while(fin.eof()==0) fin.getline(ch,20); cout<<ch; cout<<"\n"; fin.close(); getch();
C++ Exception Handling 1
C++ Exception Handling 1 An exception is a problem that arises during the execution of a program. A C++ exception is a response to an exceptional circumstance that arises while a program is running, such
More informationData type of a pointer must be same as the data type of the variable to which the pointer variable is pointing. Here are a few examples:
Unit IV Pointers and Polymorphism in C++ Concepts of Pointer: A pointer is a variable that holds a memory address of another variable where a value lives. A pointer is declared using the * operator before
More informationC++ TEMPLATES. Templates are the foundation of generic programming, which involves writing code in a way that is independent of any particular type.
C++ TEMPLATES http://www.tutorialspoint.com/cplusplus/cpp_templates.htm Copyright tutorialspoint.com Templates are the foundation of generic programming, which involves writing code in a way that is independent
More informationJayaram college of Engineering and Technology, Pagalavadi. CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT
CS2203 Object Oriented Programming Question Bank Prepared By: S.Gopalakrishnan, Lecturer/IT Two Mark Questions UNIT - I 1. DEFINE ENCAPSULATION. Encapsulation is the process of combining data and functions
More informationS.E Computer (First Semester) Examination 2016 OBJECT ORIENTED PROGRAMMING (2015 Pattern) Nov / Dec 2016 Time : 2 Hours Maximum Marks : 50
S.E Computer (First Semester) Examination 2016 OBJECT ORIENTED PROGRAMMING (2015 Pattern) Nov / Dec 2016 Time : 2 Hours Maximum Marks : 50 Q.1 a) Difference Between Procedure Oriented Programming (POP)
More informationJAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli (An approved by AICTE and Affiliated to Anna University)
Estd: 1994 JAYARAM COLLEGE OF ENGINEERING AND TECHNOLOGY Pagalavadi, Tiruchirappalli - 621014 (An approved by AICTE and Affiliated to Anna University) ISO 9001:2000 Certified Subject Code & Name : CS 1202
More informationDE70/DC56/DE122/DC106 OBJECT ORIENTED PROGRAMMING WITH C++ DEC 2015
Q.2 a. Define Object-oriented programming. List and explain various features of Object-oriented programming paradigm. (8) 1. Inheritance: Inheritance as the name suggests is the concept of inheriting or
More informationOBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak
OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction
More informationObject-Oriented Programming (OOP) Fundamental Principles of OOP
Object-Oriented Programming (OOP) O b j e c t O r i e n t e d P r o g r a m m i n g 1 Object-oriented programming is the successor of procedural programming. The problem with procedural programming is
More informationSTUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING
OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming
More informationObject Oriented Pragramming (22316)
Chapter 1 Principles of Object Oriented Programming (14 Marks) Q1. Give Characteristics of object oriented programming? Or Give features of object oriented programming? Ans: 1. Emphasis (focus) is on data
More informationPROGRAMMING IN C++ COURSE CONTENT
PROGRAMMING IN C++ 1 COURSE CONTENT UNIT I PRINCIPLES OF OBJECT ORIENTED PROGRAMMING 2 1.1 Procedure oriented Programming 1.2 Object oriented programming paradigm 1.3 Basic concepts of Object Oriented
More informationUNIT I DATA ABSTRACTION & OVERLOADING. Overview of C++: The compilation process
UNIT I DATA ABSTRACTION & OVERLOADING Overview of C++: The compilation process When you write a program in C++, your first step is to create a file that contains the text of the program, which is called
More informationObject Oriented Programming
F.Y. B.Sc.(IT) : Sem. II Object Oriented Programming Time : 2½ Hrs.] Prelim Question Paper Solution [Marks : 75 Q.1 Attempt the following (any THREE) [15] Q.1(a) Explain encapsulation? [5] (A) The wrapping
More informationAC55/AT55 OBJECT ORIENTED PROGRAMMING WITH C++ DEC 2013
Q.2 a. Discuss the fundamental features of the object oriented programming. The fundamentals features of the OOPs are the following: (i) Encapsulation: It is a mechanism that associates the code and data
More informationI BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination. June, 2015 BCS-031 : PROGRAMMING IN C ++
No. of Printed Pages : 3 I BCS-031 BACHELOR OF COMPUTER APPLICATIONS (BCA) (Revised) Term-End Examination 05723. June, 2015 BCS-031 : PROGRAMMING IN C ++ Time : 3 hours Maximum Marks : 100 (Weightage 75%)
More informationAN OVERVIEW OF C++ 1
AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function
More informationDarshan Institute of Engineering & Technology for Diploma Studies
1. Explain Call by Value vs. Call by Reference Or Write a program to interchange (swap) value of two variables. Call By Value In call by value pass value, when we call the function. And copy this value
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING CS6456 OBJECT ORIENTED PROGRAMMING Unit I : OVERVIEW PART A (2 Marks) 1. Give some characteristics of procedure-oriented
More informationI BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.
Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'
More informationSRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR
SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name
More informationAbsolute C++ Walter Savitch
Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents
More informationC++_ MARKS 40 MIN
C++_16.9.2018 40 MARKS 40 MIN https://tinyurl.com/ya62ayzs 1) Declaration of a pointer more than once may cause A. Error B. Abort C. Trap D. Null 2Whice is not a correct variable type in C++? A. float
More informationOBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe
OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++
More informationMAHARASHTRA STATE BOARD OF TECHNICAL EDUCATION (Autonomous) (ISO/IEC Certified) Subject Name: Object Oriented Programming
Important Instructions to examiners: 1) The answers should be examined by key words and not as word-to-word as given in themodel answer scheme. 2) The model answer and the answer written by candidate may
More informationSTRUCTURING OF PROGRAM
Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the
More informationPreface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.
Preface to the Second Edition p. iii Preface to the First Edition p. vi Brief Contents p. ix Introduction to C++ p. 1 A Review of Structures p. 1 The Need for Structures p. 1 Creating a New Data Type Using
More informationInterview Questions of C++
Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.
More informationDepartment of Computer science and Engineering Sub. Name: Object oriented programming and data structures Sub. Code: EC6301 Sem/Class: III/II-ECE Staff name: M.Kavipriya Two Mark Questions UNIT-1 1. List
More informationChapter 15 - C++ As A "Better C"
Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference
More informationIntroduction to Programming Using Java (98-388)
Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;
More informationRAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS
RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING YEAR/SEM:II & III UNIT I 1) Give the evolution diagram of OOPS concept. 2) Give some
More informationCS304 Object Oriented Programming Final Term
1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing
More informationData Structures and Programming with C++
Data Structures and Programming with C++ By Dr. Atul Kumar Dwivedi ETC, BIT, Durg UNIT-I B. E., V Semester Outline Basic concepts of Object oriented Programming (OOPs) 1. Objects 2. Classes 3. Data encapsulation
More informationKapil Sehgal PGT Computer. Science Ankleshwar Gujarat Chapter 6 Inheritance Extending a Class
Chapter 6 Inheritance Extending a Class Introduction; Need for Inheritance; Different form of Inheritance; Derived and Base Classes; Inheritance and Access control; Multiple Inheritance Revisited; Multilevel
More informationGovernment Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING
Government Polytechnic, Muzaffarpur. Name of the Lab: OBJECT ORIENTED PROGRAMMING THROUGH C++ Practical: OOPS THROUGH C++ Subject Code: 1618407 PROGRAM NO.1 Programming exercise on executing a Basic C++
More informationInheritance, and Polymorphism.
Inheritance and Polymorphism by Yukong Zhang Object-oriented programming languages are the most widely used modern programming languages. They model programming based on objects which are very close to
More informationPaytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value
Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object
More informationCS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE
CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate
More informationObject Oriented Programming. Solved MCQs - Part 2
Object Oriented Programming Solved MCQs - Part 2 Object Oriented Programming Solved MCQs - Part 2 It is possible to declare as a friend A member function A global function A class All of the above What
More informationAn Object Oriented Programming with C
An Object Oriented Programming with C By Tanmay Kasbe Dr. Ravi Singh Pippal IDEA PUBLISHING WWW.ideapublishing.in i Publishing-in-support-of, IDEA PUBLISHING Block- 9b, Transit Flats, Hudco Place Extension
More informationWhat is Class? Remember
What is Class? The mechanism that allows you to combine data and the function in a single unit is called a class. Once a class is defined, you can declare variables of that type. A class variable is called
More informationGet Unique study materials from
Downloaded from www.rejinpaul.com VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : IV Section : EEE - 1 & 2 Subject Code
More informationObject Oriented Programming
Object Oriented Programming Course Title: Object Oriented Programming Full Marks: 60 20 20 Course No: CSC161 Pass Marks: 24 8 8 Nature of Course: Theory Lab Credit Hrs: 3 Semester: II Course Description:
More informationInstantiation of Template class
Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double
More informationCS 6301 PROGRAMMING AND DATA STRUCTURE II Dept of CSE/IT
UNIT 1 OBJECT ORIENTED PROGRAMMING FUNDAMENTALS C++ Programming features - Data Abstraction - Encapsulation - class - object - constructors static members constant members member functions pointers references
More informationIntroduction to C++ Systems Programming
Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions
More informationObject Oriented Programming. Assistant Lecture Omar Al Khayat 2 nd Year
Object Oriented Programming Assistant Lecture Omar Al Khayat 2 nd Year Syllabus Overview of C++ Program Principles of object oriented programming including classes Introduction to Object-Oriented Paradigm:Structures
More informationFile I/O Christian Schumacher, Info1 D-MAVT 2013
File I/O Christian Schumacher, chschuma@inf.ethz.ch Info1 D-MAVT 2013 Input and Output in C++ Stream objects Formatted output Writing and reading files References General Remarks I/O operations are essential
More informationShort Notes of CS201
#includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system
More informationIntroduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts
Introduction to C++ Professor Hugh C. Lauer CS-2303, System Programming Concepts (Slides include materials from The C Programming Language, 2 nd edition, by Kernighan and Ritchie, Absolute C++, by Walter
More informationOOP. Unit:3.3 Inheritance
Unit:3.3 Inheritance Inheritance is like a child inheriting the features of its parents. It is a technique of organizing information in a hierarchical (tree) form. Inheritance allows new classes to be
More informationTime : 3 hours. Full Marks : 75. Own words as far as practicable. The questions are of equal value. Answer any five questions.
XEV (H-3) BCA (6) 2 0 1 0 Time : 3 hours Full Marks : 75 Candidates are required to give their answers in their Own words as far as practicable. The questions are of equal value. Answer any five questions.
More informationCS201 - Introduction to Programming Glossary By
CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with
More informationIncreases Program Structure which results in greater reliability. Polymorphism
UNIT 4 C++ Inheritance What is Inheritance? Inheritance is the process by which new classes called derived classes are created from existing classes called base classes. The derived classes have all the
More informationOBJ. ORI.& MULT. PROG., M.C.Q. BANK, FOR UNIT -2, SECOND YEAR COMP. ENGG. SEM-4, 2012 PATTERN, U.O.P. UNIT-2
UNIT-2 Syllabus for Unit-2 Introduction, Need of operator overloading, overloading the assignment, binary and unary operators, overloading using friends, rules for operator overloading, type conversions
More informationVALLIAMMAI ENGINEERING COLLEGE
VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED
More informationPreface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS
Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...
More informationFast Introduction to Object Oriented Programming and C++
Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming
More informationObject Oriented Programming. C++ 6 th Sem, A Div Ms. Mouna M. Naravani
Object Oriented Programming C++ 6 th Sem, A Div 2018-19 Ms. Mouna M. Naravani Object Oriented Programming (OOP) removes some of the flaws encountered in POP. In OOPs, the primary focus is on data rather
More informationConstructor - example
Constructors A constructor is a special member function whose task is to initialize the objects of its class. It is special because its name is same as the class name. The constructor is invoked whenever
More informationModule Operator Overloading and Type Conversion. Table of Contents
1 Module - 33 Operator Overloading and Type Conversion Table of Contents 1. Introduction 2. Operator Overloading 3. this pointer 4. Overloading Unary Operators 5. Overloading Binary Operators 6. Overloading
More informationUnit-V File operations
Unit-V File operations What is stream? C++ IO are based on streams, which are sequence of bytes flowing in and out of the programs. A C++ stream is a flow of data into or out of a program, such as the
More informationCS304 Object Oriented Programming
1 CS304 Object Oriented Programming 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes?
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationObject Oriented Programming with c++ Question Bank
Object Oriented Programming with c++ Question Bank UNIT-1: Introduction to C++ 1. Describe the following characteristics of OOP. i Encapsulation ii Polymorphism, iii Inheritance 2. Discuss function prototyping,
More informationKapil Sehgal PGT Computer. Science Ankleshwar Gujarat
Classes Chapter 4 Classes and Objects Data Hiding and Encapsulation Function in a Class Using Objects Static Class members Classes Class represents a group of Similar objects A class is a way to bind the
More informationSome important concept in oops are 1) Classes 2) Objects 3) Data abstraction & Encapsulation. 4) Inheritance 5) Dynamic binding. 6) Message passing
Classes and Objects Some important concept in oops are 1) Classes 2) Objects 3) Data abstraction & Encapsulation. 4) Inheritance 5) Dynamic binding. 6) Message passing Classes i)theentiresetofdataandcodeofanobjectcanbemadeauserdefineddatatypewiththehelpofaclass.
More informationAbstract Data Types (ADTs) 1. Legal Values. Client Code for Rational ADT. ADT Design. CS 247: Software Engineering Principles
Abstract Data Types (ADTs) CS 247: Software Engineering Principles ADT Design An abstract data type (ADT) is a user-defined type that bundles together: the range of values that variables of that type can
More informationAC55/AT55 OBJECT ORIENTED PROGRAMMING WITH C++ DEC 2014
Q.2 a. Differentiate between: (i) C and C++ (3) (ii) Insertion and Extraction operator (iii) Polymorphism and Abstraction (iv) Source File and Object File (v) Bitwise and Logical operator Answer: (i) C
More informationIBS Technical Interview Questions
IBS Technical Interview Questions IBS Technical interview Questions mainly from C,C++ and DBMS. In Technical interview, be prepared about your favorite subject. Suppose they asked, Which is your favorite
More informationOOP THROUGH C++(R16) int *x; float *f; char *c;
What is pointer and how to declare it? Write the features of pointers? A pointer is a memory variable that stores the address of another variable. Pointer can have any name that is legal for other variables,
More informationCS201- Introduction to Programming Current Quizzes
CS201- Introduction to Programming Current Quizzes Q.1 char name [] = Hello World ; In the above statement, a memory of characters will be allocated 13 11 12 (Ans) Q.2 A function is a block of statements
More informationCS 247: Software Engineering Principles. ADT Design
CS 247: Software Engineering Principles ADT Design Readings: Eckel, Vol. 1 Ch. 7 Function Overloading & Default Arguments Ch. 12 Operator Overloading U Waterloo CS247 (Spring 2017) p.1/17 Abstract Data
More informationDHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II
DHANALAKSHMI COLLEGE OF ENGINEERING, CHENNAI DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING REWRAP TEST I CS6301 PROGRAMMING DATA STRUCTURES II Year / Semester: III / V Date: 08.7.17 Duration: 45 Mins
More informationCHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object
CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,
More informationPHY4321 Summary Notes
PHY4321 Summary Notes The next few pages contain some helpful notes that summarize some of the more useful material from the lecture notes. Be aware, though, that this is not a complete set and doesn t
More informationPESIT Bangalore South Campus
USN 1 P E PESIT Bangalore South Campus Hosur road, 1km before Electronic City, Bengaluru -100 Department of ECE INTERNAL ASSESSMENT TEST 2 Date : 03/10/2017 Marks: 40 Subject & Code : Object Oriented Programming
More informationEND TERM EXAMINATION
END TERM EXAMINATION THIRD SEMESTER [BCA] DECEMBER 2007 Paper Code: BCA 209 Subject: Object Oriented Programming Time: 3 hours Maximum Marks: 75 Note: Attempt all questions. Internal choice is indicated.
More informationKLiC C++ Programming. (KLiC Certificate in C++ Programming)
KLiC C++ Programming (KLiC Certificate in C++ Programming) Turbo C Skills: Pre-requisite Knowledge and Skills, Inspire with C Programming, Checklist for Installation, The Programming Languages, The main
More informationCHRIST THE KING BOYS MATRIC HR. SEC. SCHOOL, KUMBAKONAM CHAPTER 9 C++
CHAPTER 9 C++ 1. WRITE ABOUT THE BINARY OPERATORS USED IN C++? ARITHMETIC OPERATORS: Arithmetic operators perform simple arithmetic operations like addition, subtraction, multiplication, division etc.,
More informationModern C++ for Computer Vision and Image Processing. Igor Bogoslavskyi
Modern C++ for Computer Vision and Image Processing Igor Bogoslavskyi Outline Move semantics Classes Operator overloading Making your class copyable Making your class movable Rule of all or nothing Inheritance
More informationPOLYMORPHISM 2 PART. Shared Interface. Discussions. Abstract Base Classes. Abstract Base Classes and Pure Virtual Methods EXAMPLE
Abstract Base Classes POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors class B { // base class virtual void m( ) =0; // pure virtual function class D1 : public
More informationPOLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors
POLYMORPHISM 2 PART Abstract Classes Static and Dynamic Casting Common Programming Errors CSC 330 OO Software Design 1 Abstract Base Classes class B { // base class virtual void m( ) =0; // pure virtual
More informationCS3157: Advanced Programming. Outline
CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching
More informationLesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)
Lesson Plan Name of the Faculty Discipline Semester :Mrs. Reena Rani : Computer Engineering : IV Subject: OBJECT ORIENTED PROGRAMMING USING C++ Lesson Plan Duration :15 weeks (From January, 2018 to April,2018)
More informationData Structures using OOP C++ Lecture 3
References: th 1. E Balagurusamy, Object Oriented Programming with C++, 4 edition, McGraw-Hill 2008. 2. Robert L. Kruse and Alexander J. Ryba, Data Structures and Program Design in C++, Prentice-Hall 2000.
More informationMAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI
MAHALAKSHMI ENGINEERING COLLEGE B TIRUCHIRAPALLI 621213 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Sub code: CS2203 SEM: III Sub Name: Object Oriented Programming Year: II UNIT-I PART-A 1. What is
More informationMAN4A OBJECT ORIENTED PROGRAMMING WITH C++ Unit I - V
MAN4A OBJECT ORIENTED PROGRAMMING WITH C++ Unit I - V MAN4B Object Oriented Programming with C++ 1 UNIT 1 Syllabus Principles of object oriented programming(oops), object-oriented paradigm. Advantages
More informationQuiz Start Time: 09:34 PM Time Left 82 sec(s)
Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability
More information22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time: 3 Hrs.
Scheme I Sample Question Paper Program Name : Computer Engineering Program Group Program Code : CO/CM/IF/CW Semester : Third 22316 Course Title : Object Oriented Programming using C++ Max. Marks : 70 Time:
More informationPolymorphism. Zimmer CSCI 330
Polymorphism Polymorphism - is the property of OOP that allows the run-time binding of a function's name to the code that implements the function. (Run-time binding to the starting address of the code.)
More informationC++ Memory Map. A pointer is a variable that holds a memory address, usually the location of another variable in memory.
Pointer C++ Memory Map Once a program is compiled, C++ creates four logically distinct regions of memory: Code Area : Area to hold the compiled program code Data Area : Area to hold global variables Stack
More informationCS201 Latest Solved MCQs
Quiz Start Time: 09:34 PM Time Left 82 sec(s) Question # 1 of 10 ( Start time: 09:34:54 PM ) Total Marks: 1 While developing a program; should we think about the user interface? //handouts main reusability
More informationObject-Oriented Programming
Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object
More informationThe Address-of Operator &: The & operator can find address occupied by a variable. If var is a variable then, &vargives the address of that variable.
VIRTUAL FUNCITONS Pointers: Some C++ tasks are performed more easily with pointers, and other C++ tasks, such as dynamic memory allocation, cannot be performed without them. As you know every variable
More informationB.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET
B.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET Course Outline The main objective of this course is to introduce students to the basic concepts of a selected language
More informationDocumentation. Programming / Documentation Slide 42
Documentation http://www.math.upb.de/~robsy/lehre/programmierkurs2008/ Programming / Documentation Slide 42 Memory Management (I) There are several types of memory which a program can access: Stack Every
More informationCome and join us at WebLyceum
Come and join us at WebLyceum For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc Go to http://www.weblyceum.com and click Register In Case of any Problem Contact Administrators Rana Muhammad
More informationWhat does it mean by information hiding? What are the advantages of it? {5 Marks}
SECTION ONE (COMPULSORY) Question #1 [30 Marks] a) Describe the main characteristics of object-oriented programming. {5 Marks Encapsulation the ability to define a new type and a set of operations on that
More information