Q. Data members and member functions of a class are private by.default. True or False?

  • (A) True
  • (B) False
  • (C) Depends on code
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (A) True

Q. Under which pillar of OOPS does base class and derived class relationship come?

  • (A) Polymorphism
  • (B) Inheritance
  • (C) Encapsulation
  • (D) Abstraction
πŸ’¬ Discuss
βœ… Correct Answer: (B) Inheritance

Q. Which of the following functions can be inherited from base class?

  • (A) Constructor
  • (B) Destructor
  • (C) Static
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (D) None

Q. Find the output of the following program.

Code:
main(){
  Float a = 5;
  switch(a){
     Case 5: cout <<”Brijesh”;
     Default: cout <<”Goswami”;
  }
}
  • (A) Brijesh
  • (B) Goswami
  • (C) BrijeshGoswami
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (D) Error

Q. Find the output of the following program.

Code:
main(){
  int a = 10, b, c;
  b  = a++;
  c = a;
  cout << a << “ “ <<b <<” “<< c << endl;
}
  • (A) 10 11 11
  • (B) 11 11 11
  • (C) 11 10 11
  • (D) 10 10 10
πŸ’¬ Discuss
βœ… Correct Answer: (C) 11 10 11

Q. Find the output of the following program

Code:
main(){
  int a, b = 10;
  a = 95 / 10;
  cout << a << endl;
}
  • (A) 9
  • (B) 9.5
  • (C) 10
  • (D) 9.0
πŸ’¬ Discuss
βœ… Correct Answer: (A) 9

Q. How many times will the print statement be executed?

Code:
main(){
  int i = 0;
  label:
  cout << “MCQBuddy;
  i++;
  if(i < 3){
    goto label;
  }
}
  • (A) 1 time
  • (B) 2 times
  • (C) 3 times
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (C) 3 times

Q. Find the output of the following program.

Code:
main(){
 cout <<  -10 - 10 -10;
}
  • (A) 0
  • (B) -30
  • (C) 30
  • (D) 20
πŸ’¬ Discuss
βœ… Correct Answer: (B) -30

Q. Find the output of the following program.

Code:
main(){
 int a = 10 / 0;
}
  • (A) 0
  • (B) Compilation error
  • (C) exception
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (C) exception

Q. Identify the correct escape sequence used for the new line.

  • (A) \t
  • (B) \n
  • (C) \a
  • (D) None
πŸ’¬ Discuss
βœ… Correct Answer: (B) \n