πŸ“Š Object Oriented Programming (OOP)
Q. When a copy constructor may be called?
  • (A) when an object of the class is returned by value
  • (B) when an object of the class is passed (to a function) by value as an argument
  • (C) when an object is constructed based on another object of the same class
  • (D) all
πŸ’¬ Discuss
βœ… Correct Answer: (D) all
πŸ“Š Object Oriented Programming (OOP)
Q. #include<iostream> using namespace std;
class X
{
public:
int x;
};
int main()
{
X a = {10};
X b = a;
cout <<a.x <<" " <<b.x; return 0;
}
  • (A) compiler error
  • (B) 10 followed by garbage value
  • (C) 10 10
  • (D) 10 0
πŸ’¬ Discuss
βœ… Correct Answer: (D) 10 0
πŸ“Š Object Oriented Programming (OOP)
Q. Which of the following is true about inline functions and macros.
  • (A) inline functions do type checking for parameters, macros don't
  • (B) macros cannot have return statement, inline functions can
  • (C) macros are processed by pre-processor and inline functions are processed in later stages of compilation.
  • (D) all of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) all of the above
πŸ“Š Object Oriented Programming (OOP)
Q. What is the difference between struct and class in C++?
  • (A) all members of a structure are public and structures don't have constructors and destructors
  • (B) members of a class are private by default and members of struct are public by default. when deriving a struct from a class/struct, default access-specifier for a base class/struct is public and when deriving a class, default access specifier is private.
  • (C) all members of a structure are public and structures don't have virtual functions
  • (D) all above
πŸ’¬ Discuss
βœ… Correct Answer: (B) members of a class are private by default and members of struct are public by default. when deriving a struct from a class/struct, default access-specifier for a base class/struct is public and when deriving a class, default access specifier is private.
πŸ“Š Object Oriented Programming (OOP)
Q. Which of the following is true about new when compared with malloc. 1) new is an operator, malloc is a function 2) new calls constructor, malloc doesn't 3) new returns appropriate pointer, malloc returns void * and pointer needs to typecast to appropriate type.
  • (A) 1 and 3
  • (B) 2 and 3
  • (C) 1 and 2
  • (D) all 1,2,3
πŸ’¬ Discuss
βœ… Correct Answer: (C) 1 and 2
πŸ“Š Object Oriented Programming (OOP)
Q. When class B is inherited from class A, what is the order in which the constructers of those classes are called
  • (A) class a first class b next
  • (B) class b first class a next
  • (C) class b's only as it is the child class
  • (D) class a's only as it is the parent class
πŸ’¬ Discuss
βœ… Correct Answer: (A) class a first class b next

Jump to