Consider the following class hierarchy: class Base { } class Derived : public Base { } Which of the following are true?
The relationship between the Base and Derived can be described as: Base is a Derived 0.0%
The relationship between the Base and Derived can be described as: Base has a Derived 13.0%
Derived can access only public member functions of Base 0.0%
Derived can access public and protected member functions of Base 43.0%
The following line of code is valid: Base *object = new Derived(); 43.0%
Consider the following code: #include<iostream> using namespace std; class A { public : A() { cout << "Constructor of A
"; }; ~A() ...
Constructor of B Constructor of A Destructor of A Destructor of B 0.0%
Constructor of A Constructor of B Destructor of B Destructor of A 100.0%
Constructor of B Constructor of A Destructor of B Destructor of A 0.0%
Constructor of A Constructor of B Destructor of A Destructor of B 0.0%
The sequence of construction and destruction of A and B will be compiler specific 0.0%
Consider the following code: #include<iostream> using namespace std; int main() { cout << "The value of __LINE__ is " <<__LINE__; return 0; } What will be the result when the above code...
The compilation will fail with the error - '__LINE__' : undeclared identifie 8.0%
The compilation will fail with the error - '__LINE__' unresolved identifie 0.0%
The code will compile and run without errors 91.0%
The code will crash at runtime 0.0%
Consider the following code: #include<stdio.h> int main(int argc, char* argv[]) { enum Colors { red, blue, white = 5, ...
4 0.0%
5 0.0%
6 0.0%
7 100.0%
8 0.0%
9 0.0%
The code will have compile time errors 0.0%
Consider the following code: #define SQ(a) (a*a) int answer = SQ(2 + 3); What will be the value of answer after the above code executes?
10 0.0%
11 91.0%
25 8.0%
13 0.0%
None of the above 0.0%
Consider the following code: class A { typedef int I; // private member I f(); friend I g(I); static I x; }; Which of the following are valid:
A::I A::f() { return 0; } 28.0%
A::I g(A::I p = A::x); 22.0%
A::I g(A::I p) { return 0; } 22.0%
A::I A::x = 0; 25.0%
Consider the following code: <font size=2> template<class T> void Kill(T *& objPtr) { delete objPtr; objPtr = NULL; } class MyClass { }; void Test() { MyClass *ptr = new MyClass(); Ki...
Code will Crash or Throw and Exception 0.0%
Code will Execute, but there will be a memory leak 0.0%
Code will execute properly 100.0%
Code will exhibit undefined behavio 0.0%
Consider the following statements relating to static member functions and choose the appropriate options: 1. They have external linkage 2. They do not have 'this' pointers 3. They can be declared ...
All are true 0.0%
Only 1, 2 and 4 are true 0.0%
Only 1 and 2 are true 100.0%
Only 1,3 and 4 are true 0.0%
All are false 0.0%
Consider the line of code given below and answer the question that follows. class screen; Which of the following statements are true about the class declaration above?
Incorrect syntax. The body of the class declaration is missing 0.0%
Incorrect syntax. {}; is missing 0.0%
The syntax is correct 100.0%
Incorrect syntax. {} is missing 0.0%
Incorrect syntax. Requires a * 0.0%
Consider the sample code given below and answer the question that follows: <font size=2> char **foo; /* Missing code goes here */ for(int i = 0; i < 200; i++) { foo[i...
font size=2>foo = new *char[200];</font 0.0%
font size=2>foo = new char[200];</font 0.0%
font size=2>foo = new char[200]*;</font 0.0%
font size=2>foo = new char*[200];</font 100.0%
font size=2>foo = new char[][200];</font 0.0%
Consider the sample code given below and answer the question that follows. 1 class Car 2 { 3 private: 4 int Wheels; 5 6 public: 7 Car(int wheels = 0) 8 : Wheels(wheels) 9 { 10 ...
4 100.0%
7 0.0%
8 0.0%
14 0.0%
19 0.0%
Consider the sample code given below and answer the question that follows. class Person { string name; int age; Person *spouse; public: Person(string sName); Person(st...
Person(string sName); 0.0%
Person(string sName, int nAge); 0.0%
Copy(Person *p); 0.0%
Person(const Person &p); 100.0%
Copy(const Person &p)? 0.0%
Consider the sample code given below and answer the question that follows. class Person { public: Person(); virtual ~Person(); }; class Student : public Person { public: Stu...
To make it impossible for this particular destructor to be overloaded 0.0%
To ensure that correct destructor is called when p is deleted 11.0%
To ensure that the destructors are called in proper orde 88.0%
To improve the speed of class Person's destruction 0.0%
To prevent the Person class from being instantiated directly making it an abstract base class 0.0%
Consider the sample code given below and answer the question that follows. template <class T> Run(T process); Which one of the following is an example of the sample code given above?
A non-template member function 0.0%
A template function definition 0.0%
A template function declaration 100.0%
A template class definition 0.0%
A template class declaration 0.0%
Consider the sample code given below and answer the question that follows. class Shape { public: virtual void draw() = 0; }; class Rectangle: public Shape { public: void draw() { // Code to draw r...
Object objShape of Shape class will be created 0.0%
A compile time error will be generated because you cannot declare Shape objects 100.0%
A compile time error will be generated because you cannot call draw function of class 'Shape' 0.0%
A compile time error will be generated because the derived class's draw() function cannot override the base class draw() function 0.0%
None of the above 0.0%
If input and output operations have to be performed on a file, an object of the _______ class should be created.
fstream 100.0%
iostream 0.0%
ostream 0.0%
istream 0.0%
None 0.0%
In the given sample Code, is the constructor definition valid? class someclass { int var1, var2; public: someclass(int num1, int num2) : var1(num1), var2(num2) { } };
Yes, it is valid 100.0%
No, we cannot assign values like this 0.0%
No, the parenthesis cannot be empty 0.0%
No, var1 and var2 are not functions but are variables 0.0%
Sample Code typedef char *monthTable[3]; Referring to the code above, which of the following choices creates two monthTable arrays and initializes one of the two?
monthTable(winter,spring={"March","April","May"}); 0.0%
monthTable winter, spring; 0.0%
monthTable, winter, spring; 0.0%
monthTable, winter,spring={"March","April","May"}; 0.0%
monthTable winter,spring={"March","April","May"}; 100.0%
What access specifier allows only the class or a derived class to access a data membe
private 0.0%
protected 100.0%
default 0.0%
virtual 0.0%
public 0.0%
What does ADT stand for?
Accessible derived type 0.0%
Access to derived type 0.0%
Abstract data type 100.0%
Abstract derived type 0.0%
Accessible data type 0.0%
What is the output of the following code segment? int n = 9; int *p; p=&n; n++; cout << *p+2 << "," << n;
11,9 0.0%
9,10 0.0%
12,10 100.0%
11,10 0.0%
What linkage specifier do you use in order to cause your C++ functions to have C linkage
extern "C" 100.0%
extern C 0.0%
_stdcall 0.0%
_cdecl 0.0%
_fastcall? 0.0%
What will be the output of the following code? class b { int i; public: virtual void vfoo() { cout <<"Base "; } }; class d1 : public b { int j; public: ...
Base Base 0.0%
Base Derived 100.0%
Derived Base 0.0%
Derived Derived 0.0%
Which of the following are NOT valid C++ casts
dynamic_cast 0.0%
einterpret_cast 0.0%
static_cast 0.0%
const_cast 0.0%
void_cast 100.0%
Which of the following are true about class member functions and constructors?
A constructor can return values but a member function cannot 0.0%
A member function can declare local variables but a constructor cannot 0.0%
A member function can return values but a constructor cannot 100.0%
A constructor can declare local variables but a member function cannot 0.0%
A member function can throw exceptions but a constructor cannot 0.0%
Which of the following member functions can be used to add an element in an std::vector?
add 0.0%
front 0.0%
push 0.0%
push_back 100.0%
Which of the following sets of functions do not qualify as overloaded functions?
void fun(int, char *) void fun(char *,int) 0.0%
void x(int,char) int *x(int,char) 100.0%
int get(int) int get(int,int) 0.0%
void F(int *) void F(float *) 0.0%
All of the above are overloaded functions 0.0%
Which of the following statements about function overloading, is true?
C++ and namespaces should be used to replace occurrences of function overloading 0.0%
Overloaded functions may not be declared as "inline" 12.0%
Although the return types and parameter types of overloaded functions can be different, the actual number of parameters cannot change 0.0%
Function overloading is possible in both C and C++ 75.0%
The parameter lists and const keyword are used to distinguish functions of the same name declared in the same scope 12.0%
Which of the following statements regarding functions are false?
Functions can be overloaded 0.0%
Functions can return the type void 0.0%
Inline functions are expanded during compile time to avoid invocation overhead 0.0%
You can create arrays of functions 100.0%
You can pass values to functions by reference arguments 0.0%
You can return values from functions by reference arguments 0.0%
A function can return a pointe 0.0%
Which of the following STL classes is deprecated (i.e. should no longer be used)?
ostrstream 100.0%
ostringstream 0.0%
ostream 0.0%
wostream 0.0%
You want the data member of a class to be accessed only by itself and by the class derived from it. Which access specifier will you give to the data member?
Public 0.0%
Private 0.0%
Protected 100.0%
Friend 0.0%
Either Public or Friend 0.0%