1) By default, all members of a class have ___________ access for all its members
a) Public
b) Protected
c) No access
d) private
2) Which operator is used to define a member of a class from outside the class definition itself?
a) ::
b) :
c) >>
d) <<
3) What is a constructor?
a) A class automatically called whenever a new object of this class is
5) If no constructor is declared, the compiler assumes the class to have a default constructor with no arguments
a)True
b) False
6) How would you read the expression x.y as?
a) member y of object pointed by x
b) member y of object x
c) member x of object y
d) All of the above
7) Which type of class has only one unique value for all the objects of that same class?
a) this
b) Friend
c) Static
d) both a and b
8) What is the output of the following code snippet?
class test
a) Public
b) Protected
c) No access
d) private
2) Which operator is used to define a member of a class from outside the class definition itself?
a) ::
b) :
c) >>
d) <<
3) What is a constructor?
a) A class automatically called whenever a new object of this class is
created.
b) A class automatically called whenever a new object of this class is
destroyed.
c) A function automatically called whenever a new object of this class is
created.
d) A function automatically called whenever a new object of this class is
destroyed.
4) Under what conditions a destructor destroys an object?
a) Scope of existence has finished
b) Object dynamically assigned and it is released using the operator
a) Scope of existence has finished
b) Object dynamically assigned and it is released using the operator
delete.
c) Program terminated.
d) Both a and b.
d) Both a and b.
a)True
b) False
a) member y of object pointed by x
b) member y of object x
c) member x of object y
d) All of the above
a) this
b) Friend
c) Static
d) both a and b
8) What is the output of the following code snippet?
class test
{
public:
static int n;
test () { n++; };
~test () { n--; };
}; int test::n=0;
int main ()
public:
static int n;
test () { n++; };
~test () { n--; };
}; int test::n=0;
int main ()
{
test a;
test b[5];
test * c = new test;
cout << a.n << endl;
delete c;
cout << test::n << endl;
return 0;
}
test a;
test b[5];
test * c = new test;
cout << a.n << endl;
delete c;
cout << test::n << endl;
return 0;
}
a) 7 6
b) 6 7
c) 5 6
d) 6 5
a) No such class exist
a) Constructor
a) class x : public y
a) True
a) A member of a friend class that can be redefined in its derived classes
c) A member of a static class that can be redefined in its derived classes
class square
a) 16
a) True
a) yes
a) Dynamic_cast
a) converts integer pointer type to any other integer pointer type
a) Yes
a) Constant expressions
b) 6 7
c) 5 6
d) 6 5
No comments:
Post a Comment