Question: 11 -
What is this operator called "?:" ?
-
relational
-
unrelational
-
casting operator
-
conditional
Answer:
conditional
Solution:
In this operator, if the condition is true means, it will return the first operator, otherwise second operator.
In this operator, if the condition is true means, it will return the first operator, otherwise second operator.
Question: 12 -
What is the use of dynamic_cast operator?
-
it will convert the operator based on precedence
-
it converts the virtual base object to derived class
-
it converts virtual base class to derived class
-
it converts the virtual base object to derived objects
Answer:
it converts virtual base class to derived class
Solution:
Because the dynamic_cast operator is used to convert from base class to derived class.
Because the dynamic_cast operator is used to convert from base class to derived class.
Question: 13 -
What will be the output of the following C++ code?#include <iostream>
using namespace std;
int main() {
int a = 5, b = 6, c;
c = (a > b) ? a : b;
cout << c;
return 0;
}
-
6
-
4
-
7
-
5
Answer:
6
Solution:
Here the condition is false on conditional operator, so the b value is assigned to c.
Here the condition is false on conditional operator, so the b value is assigned to c.
Question: 14 -
What will be the output of the following C++ code?#include <iostream>
using namespace std;
int main() {
int a = 20, b = 10, c = 15, d = 5;
int e;
e = a + b * c / d;
cout << e << endl;
return 0;
}
-
50
-
80
-
70
-
60
Answer:
60
Solution:
Scope resolution operator is having the highest precedence in c++.
Scope resolution operator is having the highest precedence in c++.
Question: 15 -
Which operator is having the highest precedence?
-
equality
-
unary
-
shift
-
postfix
Answer:
equality
Solution:
The operator which is having the highest precedence is postfix and lowest is equality.
The operator which is having the highest precedence is postfix and lowest is equality.