Sail E0 Webinar

MCQs

Total Questions : 40 | Page 1 of 4 pages
Question 1.


What will be the output of the following program?


#include
class Base
{
public:
char S, A, M;
Base(char x, char y)
{
S = y - y;
A = x + x;
M = x * x;
}
Base(char, char y = 'A', char z = 'B')
{
S = y;
A = y + 1 - 1;
M = z - 1;
}
void Display(void)
{
cout
  1.    A A A
  2.    A B A
  3.    A B C
  4.    Garbage Garbage Garbage
  5.    The program will report compile time error.
 Discuss Question
Answer: Option A. -> A A A


Question 2.


What will be the output of the following program?


#include
class Base
{
public:
int S, A, M;
Base(int x, int y)
{
S = y - y;
A = x + x;
M = x * x;
}
Base(int, int y = 'A', int z = 'B')
{
S = y;
A = y + 1 - 1;
M = z - 1;
}
void Display(void)
{
cout
  1.    65 65 65
  2.    65 66 67
  3.    A A A
  4.    A B C
  5.    The program will report compile time error.
 Discuss Question
Answer: Option A. -> 65 65 65


Question 3.


Which of the following statement is correct about the program given below?


#include
static double gDouble;
static float gFloat;
static double gChar;
static double gSum = 0;
class BaseOne
{
public:
void Display(double x = 0.0, float y = 0.0, char z = 'A')
{
gDouble = x;
gFloat = y;
gChar = int(z);
gSum = gDouble + gFloat + gChar;
cout
  1.    The program will print the output 0.
  2.    The program will print the output 120.
  3.    The program will report run-time error.
  4.    The program will report compile-time error.
  5.    The program will print the output garbage value.
 Discuss Question
Answer: Option D. -> The program will report compile-time error.


Question 4.


What is correct about the following program?


#include
class Base
{
int x, y, z;
public:
Base()
{
x = y = z = 0;
}
Base(int xx, int yy = 'A', int zz = 'B')
{
x = xx;
y = x + yy;
z = x + y;
}
void Display(void)
{
cout
  1.    The program will report compilation error.
  2.    The program will run successfully giving the output 66 65.
  3.    The program will run successfully giving the output 65 66.
  4.    The program will run successfully giving the output 66 65 65 131 196.
  5.    The program will produce the output 66 65 infinite number of times (or till stack memory overflow).
 Discuss Question
Answer: Option C. -> The program will run successfully giving the output 65 66.


Question 5.


What will be the output of the following program?


#include
class Base
{
int x, y;
public:
Base()
{
x = y = 0;
}
Base(int xx)
{
x = xx;
}
Base(int p, int q = 10)
{
x = p + q;
}objDefault(1, 1);
y = q;
}
void Display(void)
{
cout
  1.    3 2
  2.    8 3
  3.    11 6
  4.    11 10
  5.    The program will not compile successfully.
 Discuss Question
Answer: Option C. -> 11 6


Question 6.


What will be the output of the following program?


#include
class Number
{
int Num;
public:
Number(int x = 0)
{
Num = x;
}
void Display(void)
{
cout 0 ) Modify() ;
if(Dec == 10) cout
  1.    130
  2.    A0
  3.    B0
  4.    90
 Discuss Question
Answer: Option B. -> A0


Question 7.


What will be the output of the following program?


#include
class AreaFinder
{
float l, b, h;
float result;
public:
AreaFinder(float hh = 0, float ll = 0, float bb = 0)
{
l = ll;
b = bb;
h = hh;
}
void Display(int ll)
{
if(l = 0)
result = 3.14f * h * h;
else
result = l * b;
cout
  1.    0
  2.    314
  3.    314.0000
  4.    200.0000
 Discuss Question
Answer: Option A. -> 0


Question 8.


What is correct about the following program?


#include
class Addition
{
int x;
public:
Addition()
{
x = 0;
}
Addition(int xx)
{
x = xx;
}
Addition operator + (int xx = 0)
{
Addition objTemp;
objTemp.x = x + xx;
return(objTemp);
}
void Display(void)
{
cout
  1.    The program will print the output 20.
  2.    The program will report run time error.
  3.    The program will print the garbage value.
  4.    Compilation fails due to 'operator +' cannot have default arguments.
 Discuss Question
Answer: Option D. -> Compilation fails due to 'operator +' cannot have default arguments.


Question 9.


What will be the output of the following program?


#include
class BaseCounter
{
protected:
long int count;
public:
void CountIt(int x, int y = 10, int z = 20)
{
count = 0;
cout
  1.    30 10 20
  2.    Garbage 10 20
  3.    40 50 20
  4.    20 40 50
  5.    40 Garbage Garbage
 Discuss Question
Answer: Option C. -> 40 50 20


Question 10.


What will be the output of the following program?


#include
class TestDrive
{
int x;
public:
TestDrive(int xx)
{
x = xx;
}
int DriveIt(void);
};
int TestDrive::DriveIt(void)
{
static int value = 0;
int m;
m = x % 2;
x = x / 2;
if((x / 2)) DriveIt();
value = value + m * 10;
return value;
}
int main()
{
TestDrive TD(1234);
cout
  1.    300
  2.    200
  3.    Garbage value
  4.    400
 Discuss Question
Answer: Option D. -> 400


Latest Videos

Latest Test Papers