C Plus Plus Mcqs
Q.1: The value of "(sizeof(short) == sizeof(int) && sizeof(int) == sizeof(long))" isO
A. implementation defined
B. compiler error
C. false
D. true
Q.2: class A { int x; protected: int y; public: int z; }; class B: public virtual A { }; What is the privacy level of B::x?y
A. private
B. B does not inherit access to x from A.&
C. public
D. protected
Q.3: bool is_even(int i) { return i % 2 == 0; } int v[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; std::partition(v, v + 10, is_even); What is the content of array v?
A. 0,1,2,3,4,5,6,7,8,9
B. 9,8,7,6,5,4,3,2,1
C. 0,8,2,6,4,5,3,7,1,9
D. 9,1,7,3,5,4,6,2,8,0
Q.4: Which function always returns an rvalue reference from "x", which can be used to indicate the object is going to be destroyed soon?
A. std::xvalue(x)
B. std::move(x)
C. std::shift(x)
D. std::destroy(x)
Q.5: std::vector<int> v(10); std::iota(v.begin(), v.end(), 10); What is the content of vector v?b
A. 1,2,3,4,5,6,7,8,9,10
B. 10,11,12,13,14,15,16,17,18,19,20
C. 1,2,3,4,5,6,7,8,9
D. 10,11,12,13,14,15,16,17,18,19
Q.6: What is the output of the following program? int a, b = 3; const int& ar[]= {a, b}; ar[0] = 2; std::cout << ar[0];s
A. 3
B. no output; program is ill-formed
C. 0
D. 2
Q.7: What is value of x, if sizeof(int) == 4? unsigned int a = 0x98765432; unsigned int x = a >> 33;`
A. 0x98765432
B. 1
C. This is undefined behavior
D. 0
Q.8: class foo { foo(){}; }; class boo : public foo { boo() : foo() {}; }; which standard allows compilation of this code.w
A. none, the code wont compile
B. c++11
C. none, the code wont compile
D. c++98
Q.9: Is it possible to create class instance placed at a particular location in memory?R
A. Only by dirty hack with reinterpret_cast.)
B. No. Only allocation on stack or in dynamic memory is allowed.=
C. No Option
D. No Option
Q.10: int a[] {1, 2, 3}; a[[] { return 2; }()] += 2; What is the value of a[2]?J
A. 3
B. Undefined behavior
C. Compile error: malformed attribute.#
D. Compile error: malformed attribute.#

Related Mcqs

All Subject Mcqs