Sunteți pe pagina 1din 12

www.Vidyarthiplus.

com

Department Of Computer Science & Engineering


Question Bank.

Subject Code
Subject Title
Course/Branch
Semester/Year

:
:
:
:

CS2203
OBJECT ORIENTED PROGRAMMING
B.E / CSE
III Sem / II Year
UNIT I

Part A:
1. How is object oriented programming different from procedure oriented
programming? EEE may04
2. What are the element of an object model? EEE may 04
3. What is reusability ? EEE may 04
4. Give the meaning of the following operators delete , ::
5. Define 1. Object 2. Class
6. What is abstract class?
7. Define the term Data Abstraction.
8. How does structure differ from class in C++?
9. Define Encapsulation.
10. How a class is declared?
11. What are the two members of the class and how are they declared?
12. Whats the difference between the keywords struct and class?
13. Write down the special characteristics possessed by friend functions.
14. What is meant by forward declaration?
15. What are the merits and demerits of using friend function?
16. What are the special characteristics for the Static member variable?
17. Write down the properties of static member function.
18. List three reasons why it is useful to be able to inherit characteristics from parent
classes.
19. Differentiate Object oriented and Object Based programming languages. (CSE
Nov2004)
20. Comment on the following overload functions. (CSE Nov 2004)
Void inc(int I)
{
i=i+1;
}
void inc(int i, int diff=1)
{
i=i+diff;
}
21. Differentiate between overloaded and overridden functions. (CSE Nov 04)
22. Differentiate between instance members and static members.
23. What is meant by Data hiding?. (cse may 04)
24. Name the various types of multiple inheritance. (cse may 04)
1
www.Vidyarthiplus.com

www.Vidyarthiplus.com

25. What is meant by access specifier? (cse may 04)


26. Which of the following can be modeled as class in object oriented programming?
Give reasons for your answer. Aircraft, Stack, Time , Car with reg no TN 25 R
5142. (CSE Nov 03)
27. Can a member of an object be accessed via a pointer? Explain. (ECE Apr 05)
28. Can a friend be a. a friend to more than one class b. inherited.? (ECE Apr 05)
29. What is object oriented paradigm? Cse nov 05
30. Define how to invoke a member object of class? EEE May 04
31. Compare Inheritance and Delegation with respect to object oriented
programming. EEE nov 03
32. Define polymorphism with an example
33. What are the advantages offered by new operator over malloc ()?
34. Is there any difference between List x; List x(); (cse apr 04)
35. What is the difference between normal and a constant function?
36. Define volatile function.
37. Define a nesting class a company. Define a nested class employee. Show how the
employee class can be used.
38. Which of the following statements are correct ?
int const *pi = &x;
1. x=10;
2. *pi=10;
3. pi++;
4 ++ * pi
39 What is dynamic binding? When can it be used? EEE May 04
40 What is the use of this pointer
41 How many copies of static class data member will be created when instantiating
the class containing it?
42 What is the type of class for which objects cannot be created?

Part B:
1. Distinguish between pass by value and pass by reference. Explain how parameters
are passed by the above methods in C++.
2. Write a C++ program to calculate NCr using recursion.
3. Write a C++ program to print the average of the two larges elements of an array.
4. What is meant by dynamic memory management? How it is done in C++?
5. Write a program to add two integer arrays. ECE may04
6. With an example explain the following. 1. recursive funs. 2. multifunction. Ece 04
7. Write a program to count the number of words in a given statement. Ece nov 04
8. With an example show how the following are performed.
a. passing by value.
b. passing references
9. Describe the features of object oriented programming with examples.

2
www.Vidyarthiplus.com

www.Vidyarthiplus.com

10. What is object oriented programming. How it is different from procedure oriented
programming?.
11. What are inline functions? What are their advantages? Give an example. What are
rules to be followed while defining inline functions?
12. Write a C++ program to implement Stack and its operation PUSH and POP.
13. Explain nesting of classes. Give an example.
14. What are friend classes? What are the advantages and limitations of them? Give
illustrations to support your answer. (8) (cse nov 03)
15. In C++ one class can be a friend of another class. Why is this useful? Show the
coding syntax used to create this relationship, and discuss the advantages and
disadvantages of this approach.
16. Explain the following characteristics of object oriented programming with
examples. (CSE Nov 04)
Data encapsulation 2. Polymorphism 3. Genericity 4. Inheritance
17. Write a program which reads the biodata and records of 2 sessional and print the
final result make separate class for biodata, sessional 1 , sessional 2 and final result.
Then sessional 1, sessional 2 classes are derived from biodata class. Find result in
defined from sessional 1 and sessional 2 classes. Explain the concepts identify in
the program (cse apr 05)
18. Write a program that creates a class called stack and implement a stack that can be
used to store characters. (9) (ECE Apr 05)
19. Write a program to input two time objects T1 and T2 and print their sum. (10)
(ECE Apr 05)
20. Discuss about the member access controls 1. private 2. public 3. protected ECE04
21. Define a class person having data members as name of the person,names of the
parents of the person,gender,age and array containing list of hobbies.Provide
functions Findfather(),findmother() which returns the object of person class.
Provide access using function for all the functions.
22. Explain function overloading with example.
23. Write a c++ program to explain the concepts of static members and friend function.

Unit II

3
www.Vidyarthiplus.com

www.Vidyarthiplus.com

Part A
Can you have a class named main in C++? If yes how do you call its constructor?
2. What is role of constructor?
3. What is copy constructor?
4. Differentiate default constructor and
5. How does constructor differ from normal functions? Cse Nov 05
6. What is the need for explicit constructor?
7. What is the advantage of default argument in a constructor?
8. What is the difference between a default constructor provided by compiler and a
user- defined default constructor?
9. What is default constructor? When is it invoked? ECE may04
10. When will be destructor be called?
11. What are the operators of C++ that cannot be overloaded?
12. Why we need constructor in every classes and destructor in few classes?
13. List any two non overloadable operators and two operators that cannot be
overloaded with friend functions.
14. What is the significance of operator overloading?
15. List the difference between operator overloaded as a member and an operator
overloaded as a friend.
16. What are the different types of parameterized constructor and default constructor?
17. What is meant by dynamic initialization of variables?

Part B
1. What are the rules associated with constructors and destructors functions in a
class. Illustrate with examples the various ways of defining them.
2. Model a toll booth with a class called toll booth. A constructor initializes the total
no of cars and total money collected. A member function called paying car()
increments the car total add cash. The function nopaycar() increments the car
total. Finally a member functions displays the total no of cars and cash. Write a
program to implement the above statements. Ece nov04
3. Write a program that calculate the average of 100 distance values in feet. Create
an array of objects of the distance class. Implement a member function that
divides a distance value by an integer. The distance my be given as inches or feet
4. Overloading new and delete may help us in managing memory ourselves.
Explain.

4
www.Vidyarthiplus.com

www.Vidyarthiplus.com

5. What is a copy constructor? What operation does the default copy constructor
carry out? Using a short source-code example, demonstrate how a user-defined
copy constructor can provide useful functionality
6. What are the characteristics of constructor functions ? Describe various
constructors with examples (CSE Nov 04)
7. Define a C++ class matrix to describe a matrix. Equip the class with functions for
addition and multiplication. Overload the operators suitably for input and output
of the matrix. (CSE Nov 04)
8. Explain Copy cons (5). Write a program, which reads a complex no, and copy
that into another. Use copy cons to write this program (11). (cse may 04)
9. When one class inherits another, when are the class constructors called? When
are their destructors called? Ece may04
10. What is meant by overloading? How is operator overloading works?(4)
(cse may 04)
11. Write a program to add 2 complex numbers using operator overloading. What are
the operators that cant be overloaded in c++? (12) (cse may 04)
12. Write a program that employs function overloading to do the following tasks . set
all the elements of an array list to zero put each element of array list a quantity val
supplied by the users from key board(10) (ECE may 05
13. State the rules to followed while overloading an operator. Write a program to
illustrate overloading (8) CSE Nov 05
14. Define a class to model a complex number. Use constructors to initialize the
number wither with 0 or with the value of another complex number. Overload +,
<< , [] , = = suitably. EEE Nov 03
15. Write a program to overload + operator for performing addition of two template
based objects. EEE Nov 03

5
www.Vidyarthiplus.com

www.Vidyarthiplus.com

Unit III
Part A
1. What is the role of throw and catch blocks?
2. Write a program to exchange values of two variables. Use template variable as
function arguments.
3. Distinguish between overloaded functions and function templates
4. Distinguish between the terms class template and template class
5. What is an exception? How it is handled in C++?
6. When do we need multiple catch Handlers?
7. Write a program to demonstrate the concept of rethrowing an exception.
8. What are the two kinds of exception?
9. When should a function throw an exception?
10. What is the need for template function in c++? What are the advantages?
11. Distinguish between generic and non-generic arguments to function templates.
12. Why do we need to use exception-handling mechanism?
13. What should be placed in a catch block?
14. How could we specify the types of objects a function can throw?
15. Give few examples of multi arguments templates
16. What is terminate() function? Why is it need?
17. What are exception specifications?
18. What is unexpected() function ?Give an example.
19. What is uncaught_exception() function? And why do we need it?
20. What is the disadvantage of exception handling function?
21. What is the difference between inside and outside the function ?
22. What is the object destroy problem? And how can exception handling help here?

Part B
1. Explain the two models for template compilation?compare.
2. What is an exception? How it is handled in C++ programs? Explain how the
control is transferred when exceptions occur during programs execution. Write a
program to illustrate exception handling.
3. Write a brief note on the following:
[1] Class Templates
[2]Exception handling
4. Discuss the efficiency and flexibility issues with templates
5. Write a program which generate a template class by which one can perform
integer type data addition and float type data addition also (10) (cse may 04)
6. Give the syntax for function template. Write template function for
bubble sort. Write a test program to illustrate its use. (16) (CSE nov04)

6
www.Vidyarthiplus.com

www.Vidyarthiplus.com

7. Illustrate with an example how a template class can be used as a base class.
8. Write a program 1. to show how to restrict the types of exceptions that can be
thrown by a function. 2. to show how to rethrow an exception.
9. What are various types of catch? Explain with example.
10. Using time class, throw an exception when invalid time is input, write
set_terminate() to provide your own terminate function which takes care of this
problem.

7
www.Vidyarthiplus.com

www.Vidyarthiplus.com

Unit IV
Part A
1. What are the forms of inheritance?
2. Give the declaration of a class D that publicly inherits from class B, and
privately inherits from class C. (You may assume that class D has no
additional members of its own).
3. List three reasons why it is useful to be able to inherit characteristics from
parent classes.
4. Can a friend be a. a friend to more than one class b. inherited.? (ECE Apr 05)
5. Compare Inheritance and Delegation with respect to object oriented
programming. EEE nov 03
6. What are the ways in which polymorphism is implemented in C++?
7. What is virtual function? When do we need virtual functions?
8. What are the applications of this pointer?
9. When we make a virtual function pure? What are the implications of
making a function a pure virtual function?
10. Distinguish between virtual class and abstract class. EEE May 04
11. What is dynamic binding? When can it be used? EEE May 04
12. Can a virtual function be declared as static? Why? ECE may04
13. What is an abstract class? What is an polymorphic class? Ece nov04
14. How do virtual funs differ from overloaded funs? Ece nov 04
15. What is difference between public, private &protected inheritance?
16. What is the disadvantage of multiple inheritance?
17. What is difference between compile time and run time polymorphism?
18. How are the Constructor of the derived classes executed? What issues one
must considered while derived class constructor.
19. Why do we need RTTI? Suggest some cases where we need to use RTTI?
20. What are polymorphic objects?
21. What is the need for type_info object? What is role of typeid operator in the
RTTI?
22. Write down the differences between the solution provided using typeid and
solution providing dynamic cast
23. Define cons_cast and down casting
Part B:
1. What are the advantages of inheritance? Describe the various types of inheritance
supported by C++; give an example that fits them. Give the programming syntax
of implementing these forms of inheritance. How do you control the accessibility
of the members of classes involved in inheritance? (CSE Nov 03)
2. Give an application that fits the following inheritance hierarchy and write the
program for the same. Each class should have atleast two data members and two
function members. (CSE Nov 04)
Student

8
www.Vidyarthiplus.com

www.Vidyarthiplus.com

Internal

External

Results
3. A book is described by its title, name of the author and publisher and price. The
month and year of edition and its publisher describe a journal. Define classes to
model book and journals. Write methods to display the cost of the book, return
whether the book/ journal is published by a specified publisher, display the author
of the book, display whether the journal is published in the year 20000 or later.
Write a test program that creates a library with 4 books and 4 journals and display
the details of the journals published in the year in 2000 and later and the books
published by ISTE. (CSE Nov 03)
4. Give an example that fits the following inheritance hierarchy. (16) Cse Nov 05
A

5. Write a program to implement the following figure. (9) (ECE Apr 05)
person
name, age

Game
Im

readdata,
display data

Read gane
Display game

Student
Roll marks
Getdata
Computegrade
showdata

9
www.Vidyarthiplus.com

www.Vidyarthiplus.com

6. Write a C++ program to implement the example. An election is contested by 5


candidates. The candidates are numbered 1 to 5 and the voting is done by
marking the candidate number on the ballot paper. Write a program to read the
ballots and count the votes cast for each candidates using array variable count. In
case, a number read is outside the range 1 to 5 the ballot should be considered as a
spoilt ballot and the program should also count the number of spoilt ballots. Ece
may04
7. Illustrate the need of virtual base class with an example (8) (cse nov 04)
8. Discuss about Polymorphism and its advantages. (8). CSE Nov 05
9. Write a c++ program that will give the conditions of environment required, food
habits and unique characteristics of pet animals fish and dog. Define a base class
called pet that describe any common household pet; two derived classes called
fish and dog with items specific to that type of animal.. Write pure virtual
functions in the base class for operations that are common to both types of
animals. Write a program to test the usage of classes. (8) CSE Nov 05
10. Discuss about function overloading and virtual functions. ECE may04
11. Write notes on 1.abstract base class 2. late binding 3.virtual function ECE04
12. Explain why virtual base class may be necessary. Using i/o manipulators explain
how do u you format the output screen. Ece nov04
13. Suggest few cases where downcasting or cross casting is useful.
14. Draw a comparison between different casting operators
15. Design few hierarchies yourself. Identify cases where we can use virtual
functions, typeid and dynamic cast

10
www.Vidyarthiplus.com

www.Vidyarthiplus.com

UNIT V
Part A
1.
2.
3.
4.
5.
6.
7.
8.

What are streams? Why they are useful?


Illustrate with an example, how the setw and endl manipulators works.
What is the importance of ios member flags in formatting IO?
Differentate manipulators &ios functions
List out 5 manipulators & equivalent ios function
What are the various classes available for file operations?
What does the current position mean when applied to files?
What is the difference between opening a file with a constructor function and
opening a file with open() function? When is one method preferred over the
other?
9. What is file mode? Describe the various file mode options available.
10. What are the steps involved in using a file in a C++ program?
11. Describe the various approaches by which we can detect the end of file condition
successfully.
12. Describe how would you determine number of objects in a file. When do you
need such information.
13. What is the difference between opening a file with a constructor function and
opening a file with open() function? When is one method preferred over the
other?
14. What is file mode? Describe the various file mode options available.
15. What are the steps involved in using a file in a C++ program?
16. Describe the various approaches by which we can detect the end of file condition
successfully.
17. Describe how would you determine number of objects in a file. When do you
need such information.
18. What is name conflict problem? How it is solved using namespaces?
19. Differentiate USING declation and directive
20. How can we define our own namespace
21. What is unnamed namespace?
22. What is std namespace? how it is different from other namespaces?
23. What is Koenig lookup?when it is applied?
24. Define object serialization
25. List different constructor for string object
26. What are facilities available for sub string operation on string object
27. Differentiate STL &other libraries
28. What is need for iterator? What is their role in STL?
29. List different types of container

11
www.Vidyarthiplus.com

www.Vidyarthiplus.com

Part B:

1. Explain in detail about C++ Streams and the functions used by C++ stream
classes.
2. Explain the hierarchy of stream classes in C++.
3. List 2 algorithm that uses STL
4. Implement containers using stack &queue
5. Print marksheet by creating your own manipulator
6. Write a program to define a namespace 7define a employee class inside
that.define atleast 2 member function outside the namespace.write a main
program and use employee class object their
7. Write a program to compare 2 string and display if string is lexicographically
smaller than the other
8. Write an interactive menu driven program, to create a text file and display another
text file by converting each line of newly created text file into an uppercase string
Display the newly created file. In case the number of lines exceed 22, file should
be displayed one screen at a time. (10) (ece may 05)
9. Write a note on file operations. (6) (ece may 05)
10. Explain the 4 functions seekg, seekp, tellp and tellg used for setting pointers
during file operation and show how they are derived from fstream class. (6) CSE
nov 05
11. Write a c++ program to append to the contents of a file (10) CSE Nov 05
12. Write a program to write text in a file. Read the text from the file from end of
file. Display the contents of file in reverse order (80) Cse Nov 05
13. Discuss about the possible operations on a random access file. Write the
corresponding commands in turbo C++ environment. Ece may 04
14. Write a program that swaps each character pair in a text file. Eg if a file contains
1234 then after swapping the file will contain 2134
15. Write program to maintain a inventory in a shop. The class inventory has
functions store() and retrieve(). Create a small inventory file on a disk containing
a few entries. Then using random i/o allow the user to display the information
about any item by specifying its record number. Ece nov04

12
www.Vidyarthiplus.com

S-ar putea să vă placă și