CPP

CPP

Derivation and Templates has 9 Questions

Which is dependant on template parameter?

base class
abstract class
method
None of the mentioned
Which value is placed in the base class?

derived values
default type values
both a & b
None of the mentioned
How many bits of memory needed for internal representation of class?

1
2
4
no memory needed
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     class class0 
  4.     {
  5.         public:
  6.         virtual ~class0(){}
  7.         protected:
  8.         char p;
  9.         public:
  10.         char getChar();
  11.     };
  12.     class class1 : public class0 
  13.     {
  14.         public:
  15.         void printChar();
  16.     };
  17.     void class1::printChar()
  18.     {
  19.         cout  << "True" << endl;
  20.     }
  21.     int main() 
  22.     {
  23.         class1 c;
  24.         c.printChar();
  25.         return 1;
  26.     }

True
error
no output
runtime error
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     template <class T>
  4.     class A
  5.     {
  6.         public:
  7.         A(int a): x(a) {}
  8.         protected:
  9.         int x;
  10.     };
  11.     template <class T>
  12.     class B: public A<char>
  13.     {
  14.         public:
  15.         B(): A<char>::A(100) 
  16.         {
  17.             cout << x * 2 << endl;
  18.         }
  19.     };
  20.     int main()
  21.     {
  22.         B<char> test;
  23.         return 0;
  24.     }

100
200
error
runtime error
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     template <class type>
  4.     class Test
  5.     {
  6.         public:
  7.         Test();
  8.         ~Test();
  9.         type Data(type);
  10.     };
  11.     template <class type>
  12.     type Test<type>::Data(type Var0)
  13.     {
  14.         return Var0;
  15.     }
  16.     template <class type>
  17.     Test<type>::Test()
  18.     {
  19.     }
  20.     template <class type>
  21.     Test<type>::~Test()
  22.     {
  23.     }
  24.     int main(void)
  25.     {
  26.         Test<char> Var3;
  27.         cout << Var3.Data('K') << endl;
  28.         return 0;
  29.     }

k
l
error
runtime error
What is the output of this program?
  1.     #include 
  2.     using namespace std;
  3.     class Base
  4.     {
  5.         public:
  6.         Base ( )
  7.         {
  8.             cout << "1" << endl;
  9.         }
  10.         ~Base ( )
  11.         {
  12.             cout << "2" << endl;
  13.         }
  14.     };
  15.     class Derived : public Base
  16.     {
  17.         public:
  18.         Derived  ( )
  19.         {
  20.             cout << "3" << endl;
  21.         }
  22.         ~Derived ( )
  23.         {
  24.             cout << "4" << endl;
  25.         }    
  26.     }; 
  27.     int main( )
  28.     {
  29.         Derived x;
  30.     }

1234
4321
1423
1342
How many kinds of entities are directly parameterized in c++?

1
2
3
4
How many kinds of parameters are there in C++?

1
2
3
None of the mentioned