Subject Name: Object Oriented Programming with C++ Subject Code: CHAPTER NO- 1 : Concept of OOP :

L.J. Institute of Engineering & Technology Semester: IV (2016) Subject Name: Object Oriented Programming with C++ Subject Code:2140705 Faculties: Sr...
Author: Berenice Hudson
37 downloads 3 Views 892KB Size
L.J. Institute of Engineering & Technology

Semester: IV (2016)

Subject Name: Object Oriented Programming with C++ Subject Code:2140705 Faculties: Sr. No

Marks

CHAPTER NO- 1 : Concept of OOP : TOPIC:1 Introduction of OOP

1 2 3 4

1 2 3 4 5 6

7 8

9

SHORT QUESTIONS Define Encapsulation. [L.J.I.E.T]. Define Data Abstraction. [L.J.I.E.T]. Define Inheritance. [L.J.I.E.T]. Which of the following concepts of OOPS means exposing only necessary information to client? a. Encapsulation b. Abstraction c. Data Hiding d. Data binding [L.J.I.E.T]. DESCRIPTIVE QUESTIONS Compare structured programming with object oriented programming.. [L.J.I.E.T]. Explain: Abstraction and Encapsulation. [L.J.I.E.T]. Explain the concept of Class, Object, Polymorphism and Inheritance. [L.J.I.E.T]. Explain structure of class with example. [L.J.I.E.T]. Explain features of object oriented programming language.[L.J.I.E.T]. Define Following a) Define following terms I. Class II. Object III. Dynamic binding IV. Polymorphism V. Destructor [L.J.I.E.T]. Give comparison of 1. C and C++ Programming language. [L.J.I.E.T]. State the benefits of object oriented programming over procedure oriented programming. [L.J.I.E.T]. Explain following Object Oriented Programming Terms in detail.

1 1 1 1

3 3 4 (24-12-08) 5(24-12-2008) 7(17-03-2009) 7(30-12-2013) 5(10-06-2009)

7(4 -1-2010) 7(4-1-2010)

4(8-09-2009)

1) Data Abstraction 2) Polymorphism. [L.J.I.E.T]. Give comparison of 10

3.5(4-1-2010) 1. C and C++ Programming language. 2. How does main() function in C differ from C++? Give General format of Class. [L.J.I.E.T].

11

Describe the features of OOP Language. [L.J.I.E.T].

OOCP(2140705)

2016

2(17-6-2013)

7 (04-01-2010) Page 1

L.J. Institute of Engineering & Technology

Semester: IV (2016)

12

Distinguish between programming languages “C” and “C++”.[L.J.I.E.T].

7(02-01-2010)

13

List out basic concepts of Object –Oriented Programming explain each in detail.

14 15

Explain basic concepts of Object-Oriented Programming. [L.J.I.E.T]. Describe any two characteristics of OOP. [L.J.I.E.T]

7(31-03-2010) 7(02-01-2015) 7(17-06-2013) 4(05-06-2015)

16

Write the basic structure of a C++ program with all necessary blocks. . [L.J.I.E.T].

6(25-06-2014)

TOPIC:2 Procedural vs Object Oriented Programming 1

2

1 2 3

SHORT QUESTIONS You can use C++ as a procedural, as well as an object -oriented, language a. True b. False c. May be d. None of above [L.J.I.E.T]. ___________________ concepts means wrapping up of data and functions together. [L.J.I.E.T]. DESCRIPTIVE QUESTIONS Differentiate between Procedure Oriented Paradigm and Object Oriented Paradigm.[L.J.I.E.T]. Give the difference between object oriented language and procedure oriented language. [L.J.I.E.T]. Define Object and Class and Give comparison of Object Oriented Language and Procedural Language. [L.J.I.E.T].

1

1

3 4 (24-12-2008) 7(4-1-2010)

4

Define Object and Class and Give comparison of Object Oriented Language and Procedural Language. [L.J.I.E.T].

7(04-01-2010) 7(25-06-2014)

5

Write the short notes on following. [L.J.I.E.T].

4(05-01-2011)

(ii) Difference between Object Oriented and Procedure Oriented language. 6

Compare following. Object and Procedure oriented programming. [L.J.I.E.T].

3.5 (23-062011)

TOPIC:3 Priciples of OOP , Benefit and Application of OOP

1 2 3

SHORT QUESTIONS Which of the following approach is adapted by C++? a. Top-down b. Bottom-up c. Right-left d. Left-right [L.J.I.E.T]. Define Reusability . [L.J.I.E.T] DESCRIPTIVE QUESTIONS Explain the Principles of OOP. [L.J.I.E.T]. Explain the applications of OOP. [L.J.I.E.T]. Describe the features of OOP Language[L.J.I.E.T].

4

List benefits of OOP. [L.J.I.E.T].

1

2

OOCP(2140705)

1

1 7 7 7(4-1-2010) 4(05-06-2015)

2016

Page 2

L.J. Institute of Engineering & Technology 5

Semester: IV (2016)

Explain the benefits of Object Oriented Programming. [L.J.I.E.T].

7(04-01-2016)

CHAPTER NO- 2 : C++ Basics : TOPIC:1 Overview, Program Structure, Namespace, Identifier SHORT QUESTIONS 1

2

1 2

cout is a/an __________ . a. operator b. function c. object d. macro [L.J.I.E.T]. Which of the following is an abstract data type? a. int b. double c. string d. class [L.J.I.E.T]. DESCRIPTIVE QUESTIONS What is a User Defined Data type? What is the scope and life time of variable? Explain using C++ program[L.J.I.E.T]. Give comparison of Static Memory Allocation and Dynamic Memory Allocation with a code snippet. [L.J.I.E.T].

1

1

7(4-01-2010) 7(4-01-2010)

TOPIC:2 Variable, Constant,Enum,Operators, Type Casting , Control Structures 1 2

1 2 3 4 5

6 7

SHORT QUESTIONS List out memory allocation Operator. [L.J.I.E.T]. Define : Reference Variable. [L.J.I.E.T]. DESCRIPTIVE QUESTIONS Explain following with example w. r. to C++. 1. new operator Explain Scope Resolution Operator with example. [L.J.I.E.T]. Describe various operators in C++.[L.J.I.E.T]. Explain generic pointer. [L.J.I.E.T]. How do they differ ? : char const * ptr char * const ptr. [L.J.I.E.T]. What is Reference variable? What is its major use? Give Example. [L.J.I.E.T]. Explain following with example w. r. to C++.

1 1

7(23-06-2011) 3(17-6-2013) 7(30-12-2013) 7(02-01-2015) 2(17-6-2013) 2(17-6-2013)

4(17-06-2013) 7(17-6-2010)

1. new operator Explain new and delete operator.What are the advantages of new operator Over malloc? [L.J.I.E.T]. 8 9

Explain reference variables. [L.J.I.E.T]. Explain >> and >employee1 [It will ask for data member input] cout c. + d. > and = to compare weight of two bird objects, returning false if weight of first bird object is less than that of the second & true otherwise. Define main to illustrate use of above functions. [L.J.I.E.T]. Is assignment operator overloaded by default? Justify your answer. When do you overload it mandatorily? [L.J.I.E.T]. Explain type conversion from class type to basic type and one class type another class type with suitable example. [L.J.I.E.T]. What is an operator function? Write a program to overload binary + operator as member function. [L.J.I.E.T].

7(05-06-2015) 7 (04-01-2016) 7 (04-01-2016)

CHAPTER NO- 5 : Inheritance : TOPIC:1 Concept of Inheritance and Type Of Inheritance 1

SHORT QUESTIONS Which allows you to create a derived class that inherits properties from more than

OOCP(2140705)

2016

1 Page 11

L.J. Institute of Engineering & Technology

Semester: IV (2016)

1

one base class? a. Multilevel inheritance b. Multiple inheritance c. Hybrid Inheritance d. Hierarchical Inheritance[L.J.I.E.T]. Which feature in OOP allows reusing code? a. Polymorphism b. Inheritance c. Encapsulation d. Data hiding[L.J.I.E.T]. class derived: public base1, public base2 { } is an example of a. Polymorphic inheritance b. Multilevel inheritance c. Hierarchical inheritance d. Multiple inheritance[L.J.I.E.T]. A class defined within another class is: a. Nested class b. Inheritance c. Containership d. Encapsulation[L.J.I.E.T]. The major goal of Inheritance in c++ is: a. to facilitate the conversion of data types. b. to help modular programming. c. to extend the capabilities of a class. d. to hide the details of base class.[L.J.I.E.T]. Advantages of inheritance include a. providing class growth through natural selection b. facilitating class libraries c. avoiding the rewriting of code d. none of the above[L.J.I.E.T]. DESCRIPTIVE QUESTIONS What are the different types of Inheritance? [L.J.I.E.T].

2

Compare containership with inheritance. Also list the types of inheritance. [L.J.I.E.T].

3

How multiple and multilevel types of inheritance are achieved in C++? Explain with examples. [L.J.I.E.T]. Assume that Circle is defined using radius and Cylinder is defined using radius and height. Write a Circle class as base class and inherit the Cylinder class from it. Develop classes such that user can compute the area of Circle objects and volume of Cylinder objects. Area of Circle is pie *radius*radius, while volume of Cylinder is pie*(radius * radius)*height. [L.J.I.E.T]. Consider a class network as shown in figure given below. The class Employee derives information from both Account and Admin classes which in turn derive information from the class Person. Define all the four classes and write a program to create, update and display the information contained in Employee objects.

2

3

4

5

6

4

5

OOCP(2140705)

2016

1

1

1

1

1

4 7(02-01-2015) 7 7 7(30-12-2013)

7(30-12-2013)

Page 12

L.J. Institute of Engineering & Technology

Semester: IV (2016)

Person(Name,code)

Account(Pay)

Admin(Experience)

Employee(Name,code,Pay,Experience) [L.J.I.E.T].

6

What are the different forms of Inheritance? Explain each form with example.

5(10-6-2009)

7

What does inheritance mean in “C++”. What are different forms of inheritance? Explain with syntax. [L.J.I.E.T].

7(2-01-2010)

8

Write the short notes on following. . (i) Inheritance [L.J.I.E.T]. Define Inheritance. Write the types of Inheritance. Explain Inheritance with example. Consider Example with respect to print result of Student and Student Details. [L.J.I.E.T]. Explain various forms of inheritance with suitable diagrammatic illustrations. [L.J.I.E.T]. Describe multi-level and multiple inheritances. [L.J.I.E.T]. Consider the following class structure as shown in the figure. The class Result derives information from the classes Internal, University and External respectively. The Internal and External classes access information from the Student class. Define all five classes and write a suitable program to create anddisplay the information contained in Result object. [L.J.I.E.T].

4(05-01-2011)

What is inheritance? Why do we use of protected specifier for base class data

7 (04-01-2016)

9

10 11 12

13

OOCP(2140705)

2016

7(17-6-2013)

7(30-12-2013) 4 (05-06-2015) 7 (04-01-2016)

Page 13

L.J. Institute of Engineering & Technology

Semester: IV (2016)

members in inheritance? Explain hybrid inheritance with example. [L.J.I.E.T].

TOPIC:2 Protected Member , Overriding and Virtual Base Class 1

2

3

4

5

1 2 3 4 5 6 7

8 9

10 11

SHORT QUESTIONS A class hierarchy (inheritance)a. shows the same relationships as an organization chart b. describes "has a" relationships c. describes "is a kind of" relationships d. shows the same relationships as a family tree[L.J.I.E.T]. A pure virtual function is a function that: a. has no body b. returns nothing c. is used in a base class d. takes no argument[L.J.I.E.T]. ____________ is a relationship. a. Polymorphism b. Inheritance c. Overloading d. None of these option[L.J.I.E.T]. Can two classes contain member functions with the same name? a. No b. Yes, but only if the two classes have the same name. c. Yes, but only if the main program does not declare both kinds d. Yes, this is always allowed. [L.J.I.E.T]. A derived class ____________. a. Inherits data members and member functions from base class. b. Inherits constructors and destructors. c. Object can access protected members with the dot operator. d. None of the above. [L.J.I.E.T]. DESCRIPTIVE QUESTIONS Explain Virtual Base Class with example. [L.J.I.E.T]. Explain the need of Virtual base class with example. [L.J.I.E.T]. What is virtual destructor? Explain its need. Can we have virtual constructors? Why? [L.J.I.E.T]. What is a virtual function? When do we make a virtual function “pure”? What is a function template? [L.J.I.E.T]. How is polymorphism achieved at (i) compile time (ii) Run time? [L.J.I.E.T]. What is an abstract class? What is virtual base class? [L.J.I.E.T]. Explain polymorphism. How do you achieve run time polymorphism in C++?[L.J.I.E.T]. Explain different access specifiers with suitable examples[L.J.I.E.T]. Explain the following terms in brief with suitable examples (i) Pure Virtual Functions (ii) Virtual destructors (iii) Run Type identification Define and Discuss Pure Virtual Function. [L.J.I.E.T]. Distinguish between compile time polymorphism and Run Time Polymorphism with suitable examples. [L.J.I.E.T]. Write short note on Polymorphism. [L.J.I.E.T].

OOCP(2140705)

2016

1

1

1

1

1

7 3 7 3 3(17-6-2013) 7(25-06-2014) 4 7

5 7 2(17-6-2013)

3 7(17-03-2009) Page 14

L.J. Institute of Engineering & Technology

Semester: IV (2016)

4(05-01-2011)

CHAPTER NO- 6 : Polymorphism : TOPIC:1 Pointer in c++, Pointer and Object , This Pointer 1 2

3

4

1

SHORT QUESTIONS Define ‘address of’ operator. .[L.J.I.E.T]. ______________ is a derived data type that refers to another data variable by storing the variable’s memory address rather than data. a. Pointers b. Polymorphism c. Structure d. Inheritance..[L.J.I.E.T]. A pointer can be incremented and decremented by a. ++ b. – c. A and B d. A only.[L.J.I.E.T]. A ___________ pointer refers to an object that is currently invokes a member function. a. this b. these c. that d. none of above .[L.J.I.E.T]. DESCRIPTIVE QUESTIONS Explain needs and usage of this pointer.[L.J.I.E.T].

1 1

1

1

4(05-06-2015)

TOPIC:2 Virtual and Pure Virtual Function , Implementing Polymorphism 1 2 3

4

5

6

SHORT QUESTIONS What is compile time polymorphism? .[L.J.I.E.T]. What is dynamic binding? .[L.J.I.E.T]. ____________ means ‘one name, multiple forms’. a. Polymorphism b. Inheritance c. Encapsulation d. None of above.[L.J.I.E.T]. Concept of polymorphism is implemented using a. Function overloading b. Operator overloading c. A and B d. A only.[L.J.I.E.T]. An object is bound to its function call at compile time known aa. Early binding b. Compile time polymorphism c. Static binding d. All of above.[L.J.I.E.T]. We can have virtual destructor but not have constructor.

OOCP(2140705)

2016

1 1 1

1

1

1 Page 15

L.J. Institute of Engineering & Technology

7

1 2

3 4

5

6 7

Semester: IV (2016)

a. True b. False c. May be d. None of above.[L.J.I.E.T]. A virtual function, equated to zero is called _____________ a. Pure virtual function b. Virtual function c. Friend function d. None of above.[L.J.I.E.T]. DESCRIPTIVE QUESTIONS Explain Runtime polymorphism. Explain and demonstrate, how virtual function to achieve runtime polymorphism? [L.J.I.E.T]. Explain the following terms in brief with suitable examples (iv) Pure Virtual Functions (v) Virtual destructors (vi) Run Type identification Define and Discuss Pure Virtual Function. [L.J.I.E.T]. Distinguish between compile time polymorphism and Run Time Polymorphism with suitable examples. [L.J.I.E.T]. Write short note on Polymorphism. [L.J.I.E.T].

Declare a class called logic_gate to represent logic gates. The class has three data members - input1, input2 and input3 to represent three inputs to the logic gate. The class also has a virtual function member called get_gate_output. Derive two classes from the base class logic_gate, namely, and_gate and or_gate to represent ‘logical and gate’ and ‘logical or gate’ respectively. Define function get_gate_output in both of these classes to get the output of the gate. Show use of above classes and functions to demonstrate dynamic polymorphism in function main. [L.J.I.E.T]. Explain two usage of keyword virtual. [L.J.I.E.T]. What is polymorphism? How is it achieved in C++? Explain with suitable example. [L.J.I.E.T].

1

7(30-12-2013) 7 2(17-6-2013)

3 7(17-03-2009) 4(05-01-2011) 7 (05-06-2015)

4 (05-06-2015) 7 (04-01-2016)

CHAPTER NO- 7 : I/O and File Management : TOPIC:1 Concept of Streams,cin and cout Objects, c++ Stream Classes, Unformated and Formated I/O 1

2

SHORT QUESTIONS ___________ class provides the basic support for formatted and unformatted I/O operations. a. ios b. istream c. streambuf d. ostream The class ___________ provides the facilities for formatted and unformatted input. a. istream b. istream_withassign c. iostream

OOCP(2140705)

2016

1

1

Page 16

L.J. Institute of Engineering & Technology

3

1

Semester: IV (2016)

d. streambuf The class ___________ provides the facilities for formatted and unformatted output. a.ostream b. ostream_withassign c. iostream_withassign d.streambuf DESCRIPTIVE QUESTIONS (ii)Explain flags ios::binary and ios::ate.[L.J.I.E.T].

1

3(05-06-2015)

TOPIC:2 Manipulator ,File Streams and Files 1

2

3

4

5

6

1 2

SHORT QUESTIONS _________ is a sequence of bytes. a. Stream b. Input stream c. Output stream d. None of above The source stream that provides data to the program is called a. Stream b. Input stream c. Output stream d. None of above The destination stream that receives output from the program is called a. Stream b. Input stream c. Output stream d. None of above The data in the input stream can come from the a. Keyboard b. Monitor c. A and b d. None of above Which class is the base class for rest of the classes in stream classes? a. ios b. istream c. streambuf d. none of above The header file ___________ provides a set of manipulator functions to manipulate output formats. a. stdio b. iomanip c. A and B d. None of above DESCRIPTIVE QUESTIONS (i) Explain try, catch and throw. Give one simple example. (ii) Explain tellg and seekp functions. [L.J.I.E.T]. Write a program that opens two text files for reading data. It creates a third file

OOCP(2140705)

2016

1

1

1

1

1

1

7 (05-06-2015) 7(05-06-2015) Page 17

L.J. Institute of Engineering & Technology

Semester: IV (2016)

that contains the text of first file and then that of second file (text of second file to be appended after text of the first file, to produce the third file). [L.J.I.E.T]. 3 4 5

6

Explain manipulators. [L.J.I.E.T]. Explain various constructors of ofstream.. [L.J.I.E.T]. Explain various file mode parameters in C++. Write a program to copy the contents of a source file student1.txt to a destination file student2.txt character by character..[L.J.I.E.T] What is a stream? Describe various stream classes for console I/O operations in C++...[L.J.I.E.T]

3(05-06-2015) 4(05-06-2015 7(04-01-2016)

7(04-01-2016)

CHAPTER NO- 8 : Template , Exception and STL : TOPIC:1 Template,Function Template and Class Template 1 2

1

SHORT QUESTIONS Define :- Template [L.J.I.E.T]. Difference between Function Template and Class Template. [L.J.I.E.T]. DESCRIPTIVE QUESTIONS Why functions like terminate or unexpected exists when abort() and exit () functions are available? [L.J.I.E.T].

1 1

7

2

What are the problems of using macros? How does template helps in this? Explain. [L.J.I.E.T].

7

3

What is the difference between overloaded functions and function templates? Justify – Is this a legal statement – Template Class Test { };[L.J.I.E.T]. Explain Function Template Instantiation process with example of Generic Bubble Sort Function Template. [L.J.I.E.T]. Explain Class Template with Generic Stack Class example also describe the usage of Stack class for inserting student records. [L.J.I.E.T]. What is Generic Programming? How it is implemented in C++.Write General format of class templates and function Template. Write program to swap Number using Function Template. Function prototype is given below: void swap(int, int , float , float ) Swap two integer number and swap two float number..[L.J.I.E.T]. Explain with the help of an example why templates are used in programming?.[L.J.I.E.T]. Declare a template class called exam having an array of generic type as a data member, named elements[10]. Define following generic (template) member functions: - sort to arrange elements in ascending order - find_max to find and return maximum from the array Define main to illustrate usage of these functions to process two different types of data. .[L.J.I.E.T].

3

4 5 6

7 8

OOCP(2140705)

2016

7 7 2(25-06-2014) 7(17-6-2013)

7(30-12-2013) 7(05-06-2015)

Page 18

L.J. Institute of Engineering & Technology 9

Semester: IV (2016)

What is the purpose of using template in C++? Explain template function and template class with example. .[L.J.I.E.T]

7(04-01-2016)

TOPIC:2 Exception , With using Try..Catch 1 2 1

2 3 4

5 6 7 8

9 10 11 12

SHORT QUESTIONS Define :- Exception. [L.J.I.E.T]. List out the blocks used in Exception handlimg. [L.J.I.E.T]. DESCRIPTIVE QUESTIONS Explain under what circumstances the following statements would be used? (i) throw; (ii) catch(…) .[L.J.I.E.T]. What is an exception? When does a program throw an exception ? What should be placed inside a try block? What should be placed inside a catch block? .[L.J.I.E.T]. How templates function if Overloaded? Explain. .[L.J.I.E.T]. What do you mean by exception ? Describe the role of keywords try, catch and throw in exception handling. .[L.J.I.E.T]. What do you mean by Terminate and Unexpected functions? Explain. .[L.J.I.E.T]. What are major drawbacks of exception handling approach? Explain. .[L.J.I.E.T]. Explain the exception class. .[L.J.I.E.T]. What is Exception? Explain Exception HandlingMechanism.Write a program that demonstrates use of multiple catch. Add at least three catch block in your Program. .[L.J.I.E.T]. What is an exception? What are the advantages of using exception handling in a program? Illustrate C++ exception handling mechanism. .[L.J.I.E.T]. By giving an example, illustrate use and working of nested try blocks and re throwing of an exception.[L.J.I.E.T] Explain catch all exception and multiple catch exception with example. .[L.J.I.E.T] Explain the mechanism of keywords try, throw and catch to handle Exceptions in C++. Explain with an example like “division by zero” situation. .[L.J.I.E.T]

1 1 4

4 3 7 4(25-06-2014) 7(02-01-2015) 3 2 2 7(17-6-2013)

7(30-12-2013) 7(05-06-2015) 7(04-01-2016) 7(04-01-2016)

TOPIC:3 Standard Template Library 1 1

SHORT QUESTIONS List out the components of STL. [L.J.I.E.T]. DESCRIPTIVE QUESTIONS Explain STL with its core components. [L.J.I.E.T].

OOCP(2140705)

2016

1 7(02-01-2015)

Page 19