Google+ COMPUTER TRICKS, TWEAKS AND TUTORIALS: CS304 – MF-2010

CS304 – MF-2010


CS304 – MF-2010

Which part of an object exhibits its state?
Data
Operations
Any public part
Any private part

By default, which  access level is assigned to members of a class?
Public
Private
Local
protected

Which one of the following features of OOP is used to deal with only relevant details?
Abstraction
Information hiding
Object
Inheritance

Base class can always be replaced by derived class,
True
False

In inheritance, a child class is a sub-type of base class.
True
False

If MyClass has a destructor its name will be,
MyClass
~MyClass
My~Class
MyClass~

We can get only one unique value which can be used by all the objects of that class by the use of,
static variables
dynamic variables
instance variables
data members

Constant objects cannot change their state,
True
False

thispointer does not point to current object of any class,
True
False

Which one is the correct way to initialize static variables
Student int::noOfStudent 0 0;
Student::noOf Student = 0;
int Student::noOf Students = 0;
int Student::noOfStudent(0)=0

The keyword friend can not appear in,
the class allowing access to another class.
the class desiring access to another class.
the private section of a class.
the public section of a class.

Why we should avoid the use of friend function/class?
friend function/class minimizes encapsulation
difficult to use
decreases complexity
none of the given

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

Which operator can not be overloaded?
The relation operator ( >= )
Assignment operator ( = )
Script operator ( [] )
Conditional operator (? : )

How many arguments are required in the definition of an overloaded unary operator?
1
None
.5
1.5

An overloaded operator always requires one less argument than its number of operands.
True
False

To convert from a user-defined class to a basic type, you would most likely use
a built-in conversion operator.
a one-argument constructor.
an overloaded = operator.
a conversion operator that’s a member of the class.

We achieve independence of internal implementation from its external interface through-----------
Encapsulation
Information Hiding
Abstraction
both encapsulation and information hiding

A generic class showing all the common attributes and a behavior of other classes represents a very important feature in oop called --------
Inheritance
Encapsulation
Polymarphism
Abstraction

Destructor has the same name as the constructor
True
False

 Fill in the blanks below with public, protected or private keyword.                                  2

a.       Public members of base class are __________ members of derived class
b.      Protected members of base class are __________members of derived class.


 Suppose we have a class as given below,                                                                              2
Class Date{
…..
}
We create its two objects obj1 and obj2 as shown below,
Date obj1;
Date obj2 = obj1;

You have to tell which constructor will be called for the creation of obj1 and which constructor will be called for the creation of obj2 from the list of two available constructors,
a.       Default constructor
b.      Default Copy constructor

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(y),y(x)
{
            …
}


 Write three important properties of constructors?                     3

 Briefly describe the use of static data member with the help of an example.                      5

Writ c++ code to overload subscript[] operator for String class.                             5