Home / Engineering / CPP Programming MCQs / Page 4

CPP Programming MCQs | Page - 4

Dear candidates you will find MCQ questions of CPP Programming here. Learn these questions and prepare yourself for coming examinations and interviews. You can check the right answer of any question by clicking on any option or by clicking view answer button.

M

Mr. Dubey • 51.43K Points
Coach

Q. 31) How C++ compiler does differ between overloaded postfix and prefix operators?

(A) C++ doesn’t allow both operators to be overloaded in a class
(B) A postfix ++ has a dummy parameter
(C) A prefix ++ has a dummy parameter
(D) By making prefix ++ as a global function and postfix as a member function.
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 32) Which of the following operator functions cannot be global?

(A) new
(B) delete
(C) Conversion Operator
(D) All of the above
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 33) Which of the following is true about this pointer?

(A) It is passed as a hidden argument to all function calls
(B) It is passed as a hidden argument to all non-static function calls
(C) It is passed as a hidden argument to all static functions
(D) None of the above
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 34) What is the use of this pointer?

(A) When local variable’s name is same as member’s name, we can access member using this pointer.
(B) To return reference to the calling object
(C) Can be used for chained function calls on an object
(D) All of the above
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 35) Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++?

(A) Inheritance
(B) Polymorphism
(C) Encapsulation
(D) None of the above
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 36) Output of the program?
#include<iostream>
using namespace std;
int fun(int x = 0, int y = 0, int z)
{ return (x + y + z); }
int main()
{
cout << fun(10);
return 0;
}

(A) 10
(B) 0
(C) 20
(D) Compiler Error
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 37) Output of following program?
#include <iostream>
using namespace std;
int fun(int=0, int = 0);
int main()
{
cout << fun(5);
return 0;
}
int fun(int x, int y)
{
return (x+y);
}

(A) Compiler Error
(B) 5
(C) 0
(D) 10
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 38) Which of the following is true?

(A) Static methods cannot be overloaded.
(B) Static data members can only be accessed by static methods.
(C) Non-static data members can be accessed by static methods.
(D) Static methods can only access static members (data and methods)
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 39) If a function is friend of a class, which one of the following is wrong?

(A) A function can only be declared a friend by a class itself.
(B) Friend functions are not members of a class, they are associated with it.
(C) Friend functions are members of a class.
(D) It can have access to all members of the class, even private ones.
View Answer Discuss Share

M

Mr. Dubey • 51.43K Points
Coach

Q. 40) Which one of the following is correct, when a class grants friend status to another class?

(A) The member functions of the class generating friendship can access the members of the friend class.
(B) All member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.
(C) Class friendship is reciprocal to each other.
(D) There is no such concept.
View Answer Discuss Share