Question: multiple choice: C++ 11.Suppose we have a class D derived from base class B, class B { public: // other members void func(); // other
multiple choice: C++
11.Suppose we have a class D derived from base class B,
class B
{
public:
// other members
void func();
// other members
};
void B::func() { /* body */}
class D: public B
{
public:
// other members
void func();
// other members
};
void D::func() { /* body */}
D dObj;
Make the following call using dObj as calling object:
dObj.func();
Which of the following is the version of func that is called?
a. B::func()
b. D::func()
c. This is illegal.
12.Suppose class Child is derived from class Parent that was in turn derived from class GrandParent. When we declare an object of class Child, three constructors are called: i) Child, ii) Parent, iii )GrandParent.. What is the order?
a. Child, Parent, GrandParent
b. Parent, GrandParent, Child
c. GrandParent, Child, Parent
d. GrandParent, Parent, Child
e. GrandParent, Child, Parent
13. Suppose class Child is derived from class Parent that was in turn derived from class GrandParent. When we destroy an object of class Child, three destructors are called: i) Child, ii) Parent, iii )GrandParent. What is the order?
a.Child, Parent, GrandParent
b.Parent, GrandParent, Child
c.GrandParent, Child, Parent
e.GrandParent, Parent, Child
f.GrandParent, Child, Parent
14.Which of the following is correct for opening a file and attaching it to a file named File.txt? Assume proper file inclusion and proper using directives.
a.open(outStream, File.txt, ios::app)
b.ifstream inStream;
inStream.open(File.txt);
c.ifstream inStream(File.txt);
d.ofstream inStream;
onStream.open(File.txt, ios::app);
e.ifstream inStream(File.txt, ios::app);
15.If you want to examine an input value without actually removing it from the input stream, you can apply a member function of cin to the variable ch, which you are to assume is a char type variable. Which of these does this task?
a.cin.get(ch);
b.cin.put(ch);
c.cin.peek(ch);
d.cin.putback(ch);
e.none of the above
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
