Search Papers On This Blog. Just Write The Name Of The Course

Saturday 4 December 2010

CS304- Object Oriented Programming Complete Solved Midterm Paper

MIDTERM  EXAMINATION
Spring 2010
CS304- Object Oriented Programming (Session - 6)

Question No: 1    ( Marks: 1 )    - Please choose one
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

    Question No: 2    ( Marks: 1 )    - Please choose one
What a derived class can add?
       ► New data members       ► New member functions and New friend functions
       ► New constructors and destructor       ► All of given
   



Question No: 3    ( Marks: 1 )    - Please choose one
________ is/are used to access information hidden within an object?
       ► Interface       ► Private data members       ► Private member functions
       ► Both public and private members
   
Question No: 4    ( Marks: 1 )    - Please choose one
this pointers are not accessible for static member functions.
       ► True       ► False
   
Question No: 5    ( Marks: 1 )    - Please choose one
A static member function cannot be declared.
       ► Static       ► Implicit       ► Explicit       ► Virtual
   
Question No: 6    ( Marks: 1 )    - Please choose one
C++ compiler does not allow to dynamically allocate memory for objects
       ► False       ► True
   
Question No: 7    ( Marks: 1 )    - Please choose one
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
Question No: 8    ( Marks: 1 )    - Please choose one
Friend class and friend function can be used as an alternate to each other
       ► True       ► False
   
Question No: 9    ( Marks: 1 )    - Please choose one
Which of the following operators always takes no argument if overloaded?
       ► /       ► -       ► +       ► ++
   
Question No: 10    ( Marks: 1 )    - Please choose one
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
   
Question No: 11    ( Marks: 1 )    - Please choose one
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
   
Question No: 12    ( Marks: 1 )    - Please choose one
Which operator can not be overloaded?
       ► The relation operator ( >= )       ► Assignment operator ( = )
       ► Script operator ( [] )       ► Conditional operator (? : )
   
Question No: 13    ( Marks: 1 )    - Please choose one
We achieve independence of internal implementation from its external interface through-----------
       ► Encapsulation       ► Information Hiding       ► Abstraction
       ► both encapsulation and information hiding
   
Question No: 14    ( Marks: 1 )    - Please choose one
Which one of the following is not an object association?
       ► Simple Assocation       ► Inheritance       ► Aggregation       ► Composition
   
Question No: 15    ( Marks: 1 )    - Please choose one
We capture the object attributes and behavior in Object Oriented programming using---------------
       ► Class       ► Function       ► Data Members       ► Instances
   
Question No: 16    ( Marks: 1 )    - Please choose one
The return type of a constructor is of  -------------
       ► Integer       ► Chracter       ► Double       ► No type
   
Question No: 17    ( Marks: 2 )
Can we create an array of objects for a class having default constructor?. Justify your answer.

Ans:
Question No: 18    ( Marks: 2 )
Friend functions increase ‘Data vulnerability’, what is your opinion ?

Question No: 19    ( Marks: 2 )
Explain two benefits of setter functions.

    Question No: 20    ( Marks: 3 )
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)
{
           
}

   
Question No: 21    ( Marks: 3 )
Explain what type of copy the default assignment operator "=" does when applied to objects. (shallow copy or deep copy)

   
Question No: 22    ( Marks: 5 )
 What is composition? Explain it with the help of an example.
   
Question No: 23    ( Marks: 5 )
 How we can overload Stream Extraction and Insertion Operators in c++?Give example code for Complex Number Class.



Class is not a mechanism to create objects and define user data types.
True  false

Memory is allocated to non static members only, when:
 Class is created           Object is defined         Object is initialized      
Object is created

The sub-object’s life is not dependent on the life of master class in ___________.
Composition  Aggregation  Separation  non of the given

Unary operators and assignment operator are right associative.
true          false

The >= operator can't be overloaded.
True          false

_____ is creating objects of one class inside another class.
 Association          Composition         Aggregation            Inheritance

If we are create array of objects through new operator, then
 We can call overloaded constructor through new
 We can’t call overloaded constructor through new
 We can call default constructor through new
 None of the given

Object can be declared constant with the use of Constant keyword.
True          false
__________ Operator will take only one operand.
New          int     object        none of the given

 Which of the following operator(s) take(s) one or no argument if overloaded?
++           *              %             All of the given choices

this pointer does not pass implicitly to __________ functions.
Static Member                 Non-Static Member         Instance Number   None of the given

Operator overloading is
making C++ operators work with objects. giving C++ operators more than they can handle.
giving new meanings to existing Class members.     making new C++ operators

No comments:

Post a Comment