CS2203 - Object oriented programming question bank (Part 2)
Object Oriented Concepts
PART-A (2 MARKS)
1) Write any four features of OOPS.
2) What are the Basic concepts of OOS?
3) Define objects.
4) Define class.
5) Give any four advantages of OOPS.
6) Give any four applications of OOPS.
7) Give any four applications of c++.
8) Define tokens.
9) What is keyword?
10) Rules for naming the identifiers in C++.
11) What is a scope resolution operator?
12) What do you mean by enumerated data type?
13) What are symbolic constants?
14) What do you mean by dynamic initialization of variables?
15) What are reference variable?
16) What is member-dereferencing operator?
17) What is function prototype?
18) What is an inline function?
19) Write some situations where inline expansion may not work.
20) What is a default argument?
21) What are the constant arguments?
22) What is call- by- reference?
23) What is an encapsulation?
24) What is static data member?
25) What is static member function?
26) How the objects are used as function argument?
27) Define const member.
28) Define pointers to member.
29) What is function overloading? Give an example.
30) Define structured programming.
31) Explain Object oriented programming.
32) What is function prototype in C++?
33) What are the ways to comment statement in C++?
34) Explain typecasting.
35) Define void pointer using C++.
36) When do you use :: Operator in C++?
37) Define reference variable in C++.
38) What is const qualifier?
39) When do you use bool data type?
40) What is function overloading in C++?
41) What is operator overloading in C++?
42) Define Inline Function.
43) Define class using C++.
44) When do you use this pointer?
45) What is new and delete operator?
46) Define local class in C++.
47) Define namespace in C++.
48) What is the default access level?
49) Explain friend class in C++.
50) What is virtual function?
51) Define default constructor.
52) Define abstraction.
53) What is overriding?
54) Explain the difference between Structure and class in terms of Access Modifier.
55) What is private, public and protected Inheritance?
CS2203-OBJECT ORIENTED PROGRAMMING
PART-B (16 MARKS)
1) Explain with the Basic Concepts of object oriented programming.
2) (a) Explain the elements of object oriented programming.
(b) What are the difference between reference variables and normal variables?
3) Explain about call-by-reference and return by reference.
4) (a) Describe the advantages of OOP.
(b) What are the difference between pointers to constants and constant to pointers?
5) (a) Describe the applications of OOP technology.
(b) What is function overloading? Explain with an example program.
6) Explain the merits and demerits of object oriented methodology.
7) What is friend function? What is the use of using friend functions in c++? Explain with a program.
8) What is polymorphism? Provide an example to explain it.
9) Describe Abstract base class. Illustrate an example to explain it.
10) What are the advantages of using default arguments? Explain with an example program.
11) Write a program to implement nested classes using c++.
13) Write a program to demonstrate how a static data is accessed by a static member function.
14) Write a program to get the student details and print the same using pointers to objects and pointers to members of a class. Create a class student. And use appropriate functions and data members.
CONSTRUCTORS AND OPERATOR OVERLOADING
1) Define constructor.
2) Define default constructor.
3) Define parameterized constructor.
4) Define default argument constructor.
5) What is the ambiguity between default constructor and default argument constructor?
6) Define copy constructor.
7) Define dynamic constructor.
8) Define const object.
9) Define destructor.
10) Define multiple constructors.
11) Write some special characteristics of constructor.
12) How the objects are initialized dynamically?
13) What is operator overloading in C++?
14) Define default constructor.
15) Is it possible to overload a constructor? How.
16) Difference between Overriding vs. overloading.
17) List out the operators that cannot be overloaded.
18) What is the purpose of using operator function? Write its syntax.
19) Write at least four rules for Operator overloading.
20) How will you overload Unary & Binary operator using member functions?
21) How will you overload Unary and Binary operator using Friend functions?
22) How an overloaded operator can be invoked using member functions?
23) How an overloaded operator can be invoked using Friend functions?
24) List out the operators that cannot be overloaded using Friend function.
25) What is operator overloading?
26) What is meant by casting operator and write the general form of overloaded casting operator?
27) What is overloaded function selection algorithm?
28) What is meant by pointer operators?
CS2203-OBJECT ORIENTED PROGRAMMING
PART-B (16 MARKS)
1) Explain copy constructor and destructor with suitable C++ coding.
2) Explain about Implementation of simple ADTs.
3) Explain about static member and this pointer with suitable code.
4) What is a Bit field? Explain briefly.
5) Explain about Data Handling and member function.
6) What is a virtual destructor? Explain the use of it.
7) Explain about Unary Operator and Binary Operator Overloading with program.
8) List out the rules for overloading operators with example.
9) Define a supplier class. Assume that the items supplied by any given supplier are different and varying in number. Use dynamic memory allocation in the constructor function to achieve the solution.
10) Define an examiner class. Provide all necessary data and function members to provide the following: The examiner must access answer sheets of at least one subject; He may examine answer sheets of multiple subjects; The examiner represents a college and also a university; Most of the examiners are local and represent local university; and have more than one constructor including one default and one with default argument. Provide a meaningful copy constructor.
11) For a supermarket, define a bill class. All the bill objects will contain bill number, name of clerk preparing the bill, each item with quantity and price and total amount to be paid. Total items in the bill are varying. Define dynamic memory allocation constructor for bill class such that any number of items from 1 to 50 can be accommodated in a single bill. There is an array describing each item with a price. The price is to be picked up from that array. Now overload = operator and provide reason for the need of such operator.
CLASS TEMPLATES AND EXCEPTION HANDLING
1) What is a template?
2) What is R T T I ?
3) What are generic functions and generic classes?
4) What is namespace?
5) What is the need for template functions in c++? What are their advantages?
6) Give few examples of multi-argument templates.
7) What is the difference between typename and class?
8) What is instantiation? Explain.
9) What is the difference between generic and non-generic (type and non-type) arguments to function templates?
10) What is template function and template class?
11) What are the advantages of template argument deduction? When is it not possible for the compiler to deduce the argument type?
12) Give an example explaining the need for overloading a template with another template.
13) Discuss the efficiency and flexibility issues with templates.
14) What is the difference between manually overloaded functions and template instantiation?
15) Give an example where using the default arguments are useful in class template.
16) How does the behavior of the static data members of a class template differ from the behavior of static data members of a normal class?
17) What is the need for partial specialization?
18) What is the difference between explicit specialization and partial specialization?
19) Explain two models of template compilation? Compare.
20) What are the different mechanisms of traditional error handling? What is the problem with them?
21) What is the object destroy problem? How can exception handling help here?
22) What is the role of terminate() function in exception handling? Why doesn’t the exception handling mechanism not call abort() directly?
23) What is the difference between throwing exceptions inside the function and outside the function?
24) When do we need multiple catch blocks for a single try block? Give an example.
25) What are exception specifications? In which case are they needed?
26) What is rethrow()? What is its use?
27) What is unexpected() function? Give an example to explain the need of it.
28) What is uncaught_exception() function and why do we need it? What is the need of it?
29) What are the disadvantages of the exception handling mechanism?
30) What is the importance of catch all?
1) What is the need of Templates? Explain.
2) Explain about function templates?
3) Implement selection sort as a generic function.
4) Implement quick sort as a generic function.
5) Write a program for generic queue class with two member functions, insert and delete. Use the array to implement the queue.
6) Define a stack. The class should throw an exception when the stack underflow and overflow takes place.
7) using the Time class, throw an exception when invalid time is input, write set_terminate to provide your own terminate function, which care of this problem.
8) What is uncaught exception function? Give an example.
9) What are the use of terminate() and Unexpected functions? Explain with a program.
10) How to use multiple catch functions inside a program? Explain with a program.
11) Write all blocks of exception handling? Explain with a program.
INHERITANCE and Polymorphism
1) Define basic to class type conversion with an example.
2) Define class to basic type conversion with an example.
3) Define one class to another class conversion with an example.
4) What is meant by inheritance?
5) What is meant by single inheritance?
6) What is multiple inheritances?
7) What is hierarchical inheritance?
8) What is multilevel inheritance?
9) What is hybrid inheritance?
10) What is meant by Abstract base class?
11) Write short notes on virtual base class.
12) What are Friend functions? Write the syntax
13) Write some properties of friend functions.
14) What are the virtual functions?
15) Write some of the basic rules for virtual functions
16) What are pure virtual functions? Write the syntax.
17) What is an Exception?
18) Give any rules for Virtual Functions.
19) What is Visibility mode?
20) What is public, protected, private?
21) What are virtual functions?
22) What is friend function?
23) What do you mean by inheritance?
24) What is abstraction?
25) What is polymorphism? Explain with an example.
26) What do you mean by binding of data and functions?
27) What is virtual class and friend class?
28) What do you mean by inline function?
29) What do you mean by public, private, protected and friendly?
30) When is an object created and what is its lifetime?
31) What do you mean by multiple inheritance and multilevel inheritance? Differentiate between them.
32) Difference between realloc() and free?
33) What are the main differences between procedure oriented languages and object oriented languages?
34) Why do we use virtual functions?
35) What do you mean by pure virtual functions?
36) What are virtual classes?
37) Does c++ support multilevel and multiple inheritance?
38) What are the advantages of inheritance?
39) When is a memory allocated to a class?
40) What is the difference between declaration and definition?
41) In c++ there is only virtual destructors, no constructors. Why?
42) What is late bound function call and early bound function call? Differentiate.
43) What is Dynamic Polymorphism?
44) Write a macro for swapping integers.
45) Why do we need RTTI? Suggest some cases where we need to use RTTI.
46) What are polymorphic objects?
47) What is the role of typeid object in RTTI?
48) What are the problems with the use of typeid mechanism for solving problems?
49) Draw comparison between different casting operators.
50) Suggest few cases where downcasting or cross casting is useful.
PART-B (16 MARKS)
1) What are the virtual functions? Explain their needs using a suitable example. What are the rules associated with virtual functions?
2) What are the different forms of inheritance supported in c++? Discuss on the visibility of base class members in privately and publicly inherited classes.
3) What are abstract classes? Give an example (with the program) to illustrate the use of abstract classes.
4) Explain about Code Reuse with program.
5) Discuss about Run Time Type Identifications.
6) Write notes on Typing conversions and derived class with program.
7) Explain about Exceptions Handlers and Standard Exceptions.
8) Define a student class. Inherit that into MCAStudent class and NonMCAStudent. MCAStudents inherits into GLSSTudents and NonGLSStudents. A function ShowPracticalHours can only be applied to MCAStudents. We have a base class Student pointer to a GLSStudent object. Use dynamic_cast ti check that NonMCAStudents do not ShowPracticalHours.
I/O STREAMS & FILE HANDLING
1. What are streams? Why they are useful?
2. What are input and output streams?
3. Briefly describe the class hierarchy provided by c++ for stream handling.
4. What is the difference between a text file and a binary file?
5. How can a file be opened for both reading and writing?
6. Describe the following manipulators setw(), setprecision(), setfill(),
7. What is a file pointer?
8. What is a command-line argument?
9. How will you create manipulators?
10. Write the syntax and use of getline () and write () functions.
11. What are the differences between manipulators and ios functions?
12. What is the need for string objects?
13. Compare C strings with C++ strings.
14. What is meant by object serialization?
15. What is name conflict problem? How can it be solved using namespaces?
16. How can we define our own namespace?
17. How can we define our functions inside the namespace and use them outside?
18. What is unnamed namespace? What is the use of unnamed namespace?
19. How can we extend a namespace already defined? What is its advantage?
20. What is std namespace? How it is different from other namespaces?
21. What is STL? How it is different from C++ standard library?
22. List the three types of containers.
23. What is the major difference between sequence container and an associative container?
24. What is an iterator? What are the its characteristics?
25. Explain how sequence iterators work.
26. Explain how sorted associative containers work.
27. How are the STL algorithms implemented?
28. Distinguish between the following:
a. Lists and vectors
b. Sets and maps
29) What are the input and output streams?
31) Classify the streams.
32) Difference between get (), put ().
33) How to open and close a file?
34) Write some file opening modes.
35) What is a file pointer?
36) What is command-line argument?
37) What is an error and error handling functions?
38) How will you create manipulators?
39) Write the syntax and use of getline () and write () functions.
40) Give two types of template.
41) Define try and catch.
42) Define Exception handling.
43) Define File modes.
1) Explain about Template and its types with example.
2) Discuss about Streams and stream classes
3) Write notes on Formatted and Unformatted Console I/O Operations.
4) Explain about File Pointers and Manipulations with example.
5) Discuss about manipulators and file streams with Program.
6) Write on Details about File modes and File I/O.
7) Write notes on Formatted and Unformatted Console I/O Operations.
8) Explain about File Pointers and their manipulations with example.
9) Give the differences between Manipulators and ios Functions.
10) How can we determine errors while dealing with files.
11)Explain in detail about the facilities available for substring operations on the string object?
12) Explain in detail about Sorted Associative Containers.
13) Discuss about different ways of defining namespaces.
14)Explain in detail about Adapted Containers.