This set of MCQ(multiple choice questions) focuses on the Programming in Modern C++ Week 7 Solutions.
Programming in C++ is so fundamental that all companies dealing with systems as well as application development (including web, IoT, embedded systems) have a need for the same. These include – Microsoft, Samsung, Xerox, Yahoo, Oracle, Google, IBM, TCS, Infosys, Amazon, Flipkart, etc. This course would help industry developers to be up-to-date with the advances in C++ so that they can remain at the state-of-the-art.
Course layout (Answers link)
Answers COMING SOON! Kindly Wait!
Week 0: Assignment answers
Week 1:Â Programming in C++ is Fun
Week 2: C++ as Better C.
Week 3: OOP in C++.
Week 4: OOP in C++.Â
Week 5:Â Inheritance.
Week 6: Polymorphism.Â
Week 7:Â Type Casting.
Week 8:Â Exceptions and Templates.
Week 9:Â Streams and STLÂ
Week 10:Â Modern C++
Week 11: Lambda and Concurrency.
Week 12: Move, Rvalue and STL Containers.
NOTE: You can check your answer immediately by clicking show answer button. This set of “Programming in Modern C++ Week 7 Solutions” contains 09 questions.
Now, start attempting the quiz.
Programming in Modern C++ Week 7 Solutions
Q1. Consider the following program.
What will be the virtual function table (VFT) for the class C?
a)
C :: f(C* const)
C :: h(C* const)
B :: i(B* const)
b)
A :: f(A* const)
B :: g(B* const)
C :: h(C* const)
B :: i(B* const)
c)
A :: f(A* const)
B :: h(B* const)
C :: i(C* const)
d)
A :: f(A* const)
B :: (B* const)
C :: h(C* const)
C :: i(C* const)
Answer: a)
Q2. Consider the code segment given below.
#include <iostream>
using namespace std;
int main() {
char c = 'z';
int i = 50;
char *cp = &c;
int *pd;
c = static_cast<char>(i); // LINE-1
i = static_cast<double>(c); // LINE -2
pd = static_cast<double*>(cp); // LINE-3
c = static_cast<char>(&c); // LINE-4
return 0;
}
Which line/s will give you an error?
a) LINE-1
b) LINE-2
c) LINE-3
d) LINE-4
Answer: c) LINE-3, d) LINE-4
Q3. Consider the following code segment.
#include <iostream>
using namespace std;
double incr(double* ptr) {
return (*ptr)++;
}
int main() {
double val = 3.14;
const double *ptr = &val;
val = incr(_____________); //LINE-1
cout << val;
return 0;
}
Fill in the blank at LINE-1 such that the program will print: 3.14
a) const_cast<double *>(ptr)
b) static_cast<double *>(ptr)
c) dynamic_case<double *>(ptr)
d) reinterpret_cast<double *>(ptr)
Answer: a)
Q4. Consider the code segment given below.
class M { public: virtual void f() { } };
class N : public M { };
class O : public M { public: void g() {} };
class P : public N, public O{ public: void g() { } };
How many virtual tables will be created?
a) 1
b) 2
c) 3
d) 4
Answer: d) 4
Q5. Consider the code segment.
class C1 { int a=1; };
class C2 { int b=2; };
C1 * s1 = new C1;
C2 * s2 = new C2;
Which of the following type-casting is permissible?
a) s2 = static_cast<C2*>(s1);
b) s2 = dynamic_case<C2*>(s1);
c) s2 = const_cast<C2*>(s1);
d) s2 = reinterpret_case<C2*>(s1);
Answer: d)
Q6.
Answer: c) 01011
Q7.
Answer: b), c)
Q8.
Answer: d) LINE-4
Q9.
Answer: b) 11 21 30 40
<< Prev- Programming in Modern C++ Week 6 Assignment Solutions
>> Next- Programming in Modern C++ Week 8 Assignment Solutions
DISCLAIMER: Use these answers only for the reference purpose. Quizermania doesn't claim these answers to be 100% correct. So, make sure you submit your assignments on the basis of your knowledge.
For discussion about any question, join the below comment section. And get the solution of your query. Also, try to share your thoughts about the topics covered in this particular quiz.