πŸ“Š CPP Programming
Q. 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.
πŸ’¬ Discuss
βœ… Correct Answer: (B) A postfix ++ has a dummy parameter
πŸ“Š CPP Programming
Q. Which of the following operator functions cannot be global?
  • (A) new
  • (B) delete
  • (C) Conversion Operator
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) Conversion Operator
πŸ“Š CPP Programming
Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (B) It is passed as a hidden argument to all non-static function calls
πŸ“Š CPP Programming
Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
πŸ“Š CPP Programming
Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (B) Polymorphism
πŸ“Š CPP Programming
Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (D) Compiler Error
πŸ“Š CPP Programming
Q. 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
πŸ’¬ Discuss
βœ… Correct Answer: (B) 5
πŸ“Š CPP Programming
Q. 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)
πŸ’¬ Discuss
βœ… Correct Answer: (D) Static methods can only access static members (data and methods)
πŸ“Š CPP Programming
Q. 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.
πŸ’¬ Discuss
βœ… Correct Answer: (C) Friend functions are members of a class.
πŸ“Š CPP Programming
Q. 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.
πŸ’¬ Discuss
βœ… Correct Answer: (B) All member functions of the class granted friendship have unrestricted access to the members of the class granting the friendship.

Jump to