Sail E0 Webinar

MCQs

Total Questions : 16 | Page 1 of 2 pages
Question 1. Which operator is having right to left associativity in the following?
  1.    Array subscripting
  2.    Function call
  3.    Addition and subtraction
  4.    Type cast
 Discuss Question
Answer: Option D. -> Type cast


Type cast


Question 2. What is the use of dynamic_cast operator?
  1.    it converts virtual base class to derived class
  2.    it converts virtual base object to derived objeccts
  3.    it will convert the operator based on precedence
  4.    None of the mentioned
 Discuss Question
Answer: Option A. -> it converts virtual base class to derived class


Because the dynamic_cast operator is used to convert from base class to derived class.


Question 3. Which operator is having the highest precedence?
  1.    postfix
  2.    unary
  3.    shift
  4.    equality
 Discuss Question
Answer: Option A. -> postfix


The operator which is having highest precedence is postfix and lowest is equality.


Question 4.

What is the output of this program?

#include

using namespace std;

int main()

{

int a;

a = 5 + 3 * 5;

cout

  1.    35
  2.    20
  3.    25
  4.    30
 Discuss Question
Answer: Option B. -> 20


Because the * operator is having highest precedence, So it is executed first and then the + operator will be executed.


Question 5. What is this operator called ?: ?
  1.    conditional
  2.    relational
  3.    casting operator
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> conditional


In this operator, if the condition is true means, it will return the first operator, otherwise second operator.


Question 6.

What is the output of this program?

#include < iostream >

using namespace std;

int main()

{

int a = 5, b = 6, c, d;

c = a, b;

d = (a, b);

cout

  1.    5 6
  2.    6 5
  3.    6 7
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 5 6


It is a separtor here.In c,the value a is stored in c and in d the value b is stored in d because of the bracket.


Question 7.

What is the output of this program?

#include < iostream >

using namespace std;

main()

{

double a = 21.09399;

float b = 10.20;

int c ,d;

8.        c = (int) a;

d = (int) b;

cout

  1.    20 10
  2.    10 21
  3.    21 10
  4.    none of the mentioned
 Discuss Question
Answer: Option C. -> 21 10


In this program, we are casting the operator to integer, So it is printing as 21 and 10


Question 8. What is the output of this program?#include < iostream >using namespace std;int main (){int x, y;x = 5;y = ++x * ++x;cout
  1.    749736
  2.    736749
  3.    367497
  4.    none of the mentioned
 Discuss Question
Answer: Option A. -> 749736


Because of the precedence the pre-increment and post increment operator, we got the output as 749736.


Question 9.

What is the output of this program?

#include < iostream >

using namespace std;

int main()

{

int a = 5, b = 6, c;

c = (a > b) ? a : b;

cout

  1.    6
  2.    5
  3.    4
  4.    7
 Discuss Question
Answer: Option A. -> 6


Here the condition is false on conditional operator, so the b value is assigned to c


Question 10.

What is the output of this program?

#include < iostream >

using namespace std;

int main()

{

int i, j;

j = 10;

i = (j++, j + 100, 999 + j);

cout

  1.    1000
  2.    11
  3.    1010
  4.    1001
 Discuss Question
Answer: Option C. -> 1010


j starts with the value 10. j is then incremented to 11. Next, j is added to 100. Finally, j (still containing 11) is added to 999 which yields the result 1010.


Latest Videos

Latest Test Papers