Today Paper (27-05-2010)
Spring_2010_MidTerm_OPKST_CS304
Today Paper (26-05-2010)
MIDTERM EXAMINATION
Spring 2010
CS304- Object Oriented Programming (Session - 6)
Time: 60 min
Marks: 38
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.
No comments:
Post a Comment