MIDTERM EXAMINATION Spring 2010
CS304- Object Oriented Programming
Time: 60 min
M a r k s: 38
Q. No: 1
Suppose there is an object of type Person, which of the following can be considered as one of its attributes
- Name
- Age
- Work()
- Both Name and Age
Q. No: 2
What a derived class can add?
- New data members
- New member functions and New friend functions
- New constructors and destructor
- All of given
Q. No: 3
________ is/are used to access information hidden within an object?
- Interface
- Private data members
- Private member functions
- Both public and private members
Q. No: 4
this pointers are not accessible for static member functions. vuzs
Q. No: 5
A static member function cannot be declared.
- Static
- Implicit
- Explicit
- Virtual
Q. No: 6
C++ compiler does not allow to dynamically allocate memory for objects
Q. No: 7
Given the following class
class Base{
int Age=33;
}
How you can improve above class with respect to accessing the field Age?
- Define the variable Age as private
- Define the variable Age as protected
- Define the variable Age as private and create a get method that returns it and a set method that updates it
- Define the variable Age as protected and create a set method that returns it and a get method that updates it
Q. No: 8
Friend class and friend function can be used as an alternate to each other
Q. No: 9 http://vuzs.net
Which of the following operators always takes no argument if overloaded?
Q. No: 10
Suppose that the Test class does not have an overloaded assignment operator. What happens when an assignment a=b; is given for two Test objects a and b?
- The automatic assignment operator is used
- The copy constructor is used
- Compiler error
- Run-time error
Q. No: 11
Assume a class C with objects obj1, obj2, and obj3. For the statement obj3 = obj1 - obj2 to work correctly, if the overloaded - operator must
- take two arguments.
- return a value.
- create a named temporary object.
- take four arguments
Q. No: 12
Which operator can not be overloaded?
- The relation operator ( >= )
- Assignment operator ( = )
- Script operator ( [] )
- Conditional operator (? : )
Q. No: 13 http://vuzs.net
We achieve independence of internal implementation from its external interface through------------ Encapsulation
- Information Hiding
- Abstraction
- both encapsulation and information hiding
Q. No: 14
Which one of the following is not an object association?
- Simple Association
- Inheritance
- Aggregation
- Composition
Q. No: 15 http://vuzs.net
We capture the object attributes and behavior in Object Oriented programming using---------------
- Class
- Function
- Data Members
- Instances
Q. No: 16
The return type of a constructor is of -------------
- Integer
- Character
- Double
- No type
Q. No: 17
Can we create an array of objects for a class having default constructor?. Justify your answer.
Q. No: 18
Friend functions increase ‘Data vulnerability’, what is your opinion ?
Q. No: 19
Explain two benefits of setter functions.
Q. No: 20
Consider the class given below what will be the values in variables x,y and z after creating object of this class,
class ABC{
int x;
int y;
int z;
public:
ABC();
};
ABC::ABC():x(10),z(x),y(x)
{
…
}
Q. No: 21
Explain what type of copy the default assignment operator "=" does when applied to objects. (shallow copy or deep copy)
Q. No: 22
What is composition? Explain it with the help of an example.
Q. No: 23
How we can overload Stream Extraction and Insertion Operators in c++?Give example code for Complex Number Class.