Question 1 of 25
Hints left: 3
Q1
How many real types are there in complex numbers?
Q2
How are types therein user-defined conversion?
Q3
What is string objects in C++?
Q4
Which keyword is used to define the user defined data types?
Q5
What is the return type of the conversion operator?
Q6
What is a binary operator?
Q7
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main () { string str ("Microsoft"); for (size_t i = 0; i < str.length();) { cout << str.at(i-1); } return 0; }
Q8
What will be the output of the following C++ code? #include <stdio.h> #include<iostream> using namespace std; int main() { int x = 5, y = 5, z; x = ++x; y = --y; z = x + ++x; cout << z; return 0; }
Q9
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class B { int b; public: B(){} B(int i){ b = i; } int show(){ return b; } }; class C { B b; public: C(int i){ b = B(i); } friend void show(); }; void show() { C c(10); cout<<"value of b is: "<<c.b.show()<<endl; } int main(int argc, char const *argv[]) { show(); return 0; }
Q10
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { static int a; public: void show() { a++; cout<<"a: "<<a<<endl; } }; int A::a = 5; int main(int argc, char const *argv[]) { A a; return 0; }
Q11
When struct is used instead of the keyword class means, what will happen in the program?
Q12
What will be the output of the following C++ code? #include <iostream> using namespace std; class numbers { private: int m_nValues[10]; public: int& operator[] (const int nValue); }; int& numbers::operator[](const int nValue) { return m_nValues[nValue]; } int main() { numbers N; N[5] = 4; cout << N[5]; return 0; }
Q13
Which functions of a class are called inline functions?
Q14
Pick out the correct statement.
Q15
Pick out the other definition of objects.
Q16
Pick the incorrect statements out of the following.
Q17
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; class A { int a; public: int assign(int i) const { a = i; } int return_value() const { return a; } }; int main(int argc, char const *argv[]) { A obj; obj.assign(5); cout<<obj.return_value(); }
Q18
Which operator should be overloaded in the following code to make the program error free? #include <iostream> #include <string> using namespace std; class Box{ int capacity; public: Box(){} Box(double capacity){ this->capacity = capacity; } }; int main(int argc, char const *argv[]) { Box b1(10); Box b2 = Box(14); if(b1 == b2){ cout<<"Equal"; } else{ cout<<"Not Equal"; } return 0; }
Q19
Where does keyword ‘friend’ should be placed?
Q20
What will be the output of the following C++ code? #include <iostream> #include <string> using namespace std; int main(int argc, char const *argv[]) { char str[10]; cin>>str; cout<<str; return 0; }
Q21
Which of these following members are not accessed by using direct member access operator?
Q22
What will be the output of the following C++ code? #include <stdio.h> #include<iostream> using namespace std; int main() { int a = 21; int c ; c = a++; cout << c; return 0; }
Q23
What will be the output of the following C++ code? #include <iostream> using namespace std; int main() { typedef int num; typedef char let; let w = "steve"; num a = 10, b = 15; num c = a + w; cout << c; return 0; }
Q24
What will be the output of the following C++ code? #include using namespace std; class CDummy { public: int isitme (CDummy& param); }; int CDummy::isitme (CDummy& param) { if (¶m == this) return true; else return false; } int main () { CDummy a; CDummy *b = &a; if (b->isitme(a)) { cout << "execute"; } else { cout<<"not execute"; } return 0; }
Q25
What will happen when the function call operator is overloaded?