You are on page 1of 5

Questions Bank for III Semester – 2020

Subject: Object Oriented Programming & Methodology


Subject Code: 150304

Unit-I

Objective Type Questions (One Marks)


1) Which of the following special symbol allowed in a variable name?
a) * (asterisk)
b) | (pipeline)
c) - (hyphen)
d) _ (underscore)
2) Which of the following is the correct order of evaluation for the below expression?
z=x+y*z/4%2–1
a) * / % + - = b) = * / % + - c) / * % - + = d) * % / - + =
3) Which of the following is the correct usage of conditional operators used in C++?
a) a>b ? c=30 : c=40; b) a>b ? c=30;
c) max = a>b ? a>c?a:c:b>c?b:c d) return (a>b)?(a:b)
4) If the two strings are identical, then strcmp() function returns
a)-1 b) 1 c) 0 d) yes
5) Which of the following is not logical operator?
a) & b) &&
c) || d) !

Short Answer Type Questions (Two Marks)


1) Define keywords and Identifier.
2) What are the steps in writing a function in a program?
3) What is structure? Explain the syntax of structure declaration with Example.
4) What is meant by data Encapsulation? What are its advantages?

Short Answer Type Questions (Three Marks)


1) What are operators? Explain arithmetic and relational operators.
2) Why header files are included? Specify any three header files and its use.
3) What is a pointer? Explain how pointer variable declared and initialized.
4) How does Object Oriented Approach differ from Procedure Oriented Programming?

Long Answer Type Questions (Seven Marks)


1) Compare in terms of their functions, the following form of statements.
i) While and Do while
ii) Break and Continue
2) Write a program to copy one string into other string without using strcpy() function.
3) Explain the concept of Dynamic Allocation with suitable example.
4) Explain different Parameter Passing Mechanism supported by C++. Give proper example
5) Define Object-oriented programming and Explain feature of Object oriented programming. How it is
different than procedure oriented programming.
6) Create a class DISTANCE. Create D1, D2 and D3 as objects of DISTANCE. Write a C++ program to
read the distance D1 and D2 in the form as kms and mts where kms indicates kilometers and mts
indicates meters. Assume both kms and mts to be integer only. Add then and store result in
DISTANCE D3. Finally print the value of DISTANCE D3.
Unit-II
Objective Type Questions (One Marks)
1) Which of the following concepts of OOPS means exposing only necessary information to client?
a) Encapsulation b) Abstraction c) Data hiding d) Data binding
2) Which of the following is the correct way of declaring a function as constant?
a) const int ShowData(void) { /* statements */ }
b) int const ShowData(void) { /* statements */ }
c) int ShowData(void) const { /* statements */ }
d) Both A and B
3)

Short Answer Type Questions (Two Marks)


1) Differentiate between Object and Class
2) When will the destructor be called? Is it implicit or explicit?
3) Explain important characteristics of Constructor
4) Explain friend function and list sum of the special properties of friend function.

Short Answer Type Questions (Three Marks)


1) Why data member and member functions are declared as static in any class? Explain by giving
proper example
2) What is Object Pointer? How to declare the object pointer and access the object using it?
3) “If we have a function having n arguments, then is it possible to call this function using less then n
arguments “. Explain with suitable example.
4) Write a program to count the number of objects of a certain class.

Long Answer Type Questions (Seven Marks)


1) Give an Illustration of copy Constructor, Multiple constructor and Dynamic constructor in class.
2) Write a C++ program to create a class called COMPLEX and accept 2 complex numbers, add them
and display their output. Illustrate the passing of Objects as parameters in the program.
3) Create a class DISTANCE. Create D1,D2 and D3 as objects of DISTANCE. Write a C++ program to
read the distance D1 and D2 in the form as kms and mts where kms indicates kilometers and mts
indicates meters. Assume both kms and mts to be integer only. Add then and store result in
DISTANCE D3. Finaly print the value of DISTANCE D3
4) Write a C++ program to add and multiply two complex number using constructors
5) Create a class TIME. Create T1, T2 and T3 as objects of TIME. Write a C++ program to read time T1
and T2 as hh, mm and ss. Where hh indicates hours, mm indicates minutes and ss indicate seconds.
Assume hh, mm and ss all to be integers. Add these times T1 and T2 and store the result in time
T3.Print the value of T3.

Unit-III
Objective Type Questions (One Marks)
1) Which of the following is not the member of class?
a) Static function b) Friend function c) Const function d) Virtual function
2) Which of the following is correct about the statements given below?
1). All operators can be overloaded in C++.
2). We can change the basic meaning of an operator in C++.
a). Only I is true. b) Both I and II are false c). Only II is true. d) Both I and II are true.
3)

Short Answer Type Questions (Two Marks)


1) What is Polymorphism? What do you understand by runtime and compile time polymorphism?
2) Define Operator overloading. Why is it necessary to overload an operator?
3) Why can’t friend function be used to overload assignment operator?
4) Write at least four rules for Operator overloading

Short Answer Type Questions (Three Marks)


1) Write a program to overloaded >> (insertion) and << (extraction) operator using member function
of a class
2) Write a program to overload ++ (increment) - - (decrement) operator using member function of a
class.
3) What is conversion function? How is it created? Write a program to convert user define data type to
user define data type
4) Discuss about polymorphism and its advantages.

Long Answer Type Questions (Seven Marks)


1) What are the different data type conversions possible in C++? How these conversions can be
achieved? Write a program to illustrate conversion from a user defined data types to a built in data
type.
2) Create a class called distance containing data member , meter, centimeter and millimeter overload
unary operator ++ and -- relative to distance class using member function write program to include
this class and display the result of ++ and – operator
3) Two classes one is Civil_Time and Another is Railway_Time. Enter hours and minutes in Railway
time (24 hour format) and display the time in Civil time (12 hour format with a.m. and p.m.) using
one class type to another class type conversion.
4) Discuss operator overloading? Explain how to overload unary operator and binary operator
5) Write a program using operator overloading to add two time values in the format HH:MM:SS to the
resulting time along with rounding off when 24 hrs is reached. A time class is created and operator +
is overloaded to add the two time class objects

Unit-IV

Objective Type Questions (One Marks)


1) Which of the following concepts provides facility of using object of one class inside another class?
a) Encapsulation b) Abstraction c) Composition d) Inheritance
2) Which inheritance type is used in the class given below?
a) Multilevel inheritance b) Multiple inheritance c) Hybrid Inheritance d) Hierarchical Inheritance
3) Which one of the following options is correct?
a) Friend function can access public data members of the class.
b) Friend function can access protected data members of the class.
c) Friend function can access private data members of the class.
d) All of the above.

Short Answer Type Questions (Two Marks)


1) What are Access Control Specifier? Explain the role of access specifiers in inheritance
2) What is Containership? How does it differ from inheritance?
3) What is the difference between a virtual function and a pure virtual function?
4) Write a program to initialize base class members through a derived class constructor

Short Answer Type Questions (Three Marks)


1) What is Nested Class? How does it differ from local class? Explain with example.
2) What is Virtual Function? Why virtual functions are needed give suitable example.
3) Explain public, private and protected access specifies and show their visibility when they are
inherited as public, private and protected.
4) What is the ambiguity that arises in multiple inheritance? How it can be overcome. Explain with
example.
Long Answer Type Questions (Seven Marks)
1) Create a class Employee containing protected data name and emp_no write its constructor and
destructor function. Create two derived classess Daily based containing private data member rate and
days and a class Permanent containing basic and allowances by inheriting employee class as
public(self assist). Write appropriate function in each class to calculate total salary of each employee
and to display name, emp_no and total salary.
2) Suppose that we have a class called as FATHER and a class MOTHER. Say that we have a class
CHILD which is inheriting from both FATHER and MOTHER class say that FATHER has qualities
Q1, Q2 and Q3 and MOTHER has qualities Q1, Q2 and Q4.
i) Draw diagram for this situation.
ii) Is it an example of multiple inheritance? Justify your answer.
iii) Give qualities of CHILD due to inheritance along with its explanation.
3) What are the different kinds of inheritance? Explain them with suitable examples
4) Write base class that ask the user to enter a complex number and derived class adds the complex
number of its own with the base. Finally make third class that is friend of derived and calculate the
difference of base complex number and its own complex number.
5) Write a program demonstrating use of the pure virtual function with the use of base and derived
classes

Unit-V
Objective Type Questions (One Marks)
1) Which of the following statements is correct?
a) Base class pointer cannot point to derived class.
b) Derived class pointer cannot point to base class.
c) Pointer to derived class cannot be created.
d) Pointer to base class cannot be created.
2) How many instances of an abstract class can be created?
a) 1 b) 5 c) 13 d) 0
3) Which of the following is used to make an abstract class?
a) Declaring it abstract using static keyword.
b) Declaring it abstract using virtual keyword.
c) Making at least one member function as virtual function.
d) Making at least one member function as pure virtual function.
4)

Short Answer Type Questions (Two Marks)


1) What is Fle Mode? Describe the various file mode options available
2) What are Abstract classes? Explain their use
3) Explain Association and Aggregation.
4) Explain ignore (), flush (), peek () and putback() functions.

Short Answer Type Questions (Three Marks)


1) ) Explain pure virtual function. Why is Base class constructor called inside Derived class?
2) Explain, with an example how an array of objects is created using pointers?
3) Explain Association, Aggregation and Composition with the help of example.
4) Define the ‘this’ pointer, with an example, indicate the steps involved in referring to members of the
invoking object
5)
Long Answer Type Questions (Seven Marks)
1) Write a program to copy one file into another file where source file & target file name given by user.
2) Write a program that reads a text file and creates another file that is identical except that every
sequence of consecutive blank spaces is replaced by a single space.
3) Write a program to read and write operation with objects using write() and read() function in a file. 4)
Write a Program to declare a pointer to the base class and access the member variable of base and
derived class
4) What is file? Write the types of File access? Write an example program for sequential access.
5) Discuss with examples, the implications of deriving a class from an existing class by the
‘public’and‘protected’ access specifies.

Mahesh Parmar
Assistant Professor (CSE)

You might also like