GATE-Programming Methodology Questions and Answers

Practice Mode
Showing 10 of 105 questions
Q91
Assume num= 8;. The value of the expressionnum ++ is ...........
  • A 7
  • B 8
  • C 9
  • D impossible to tell
Answer: Option C
Q92
If the ++ operator is overloaded properly, to operator ++ () function returns
  • A a copy of an incremented member of a class
  • B a copy of an incremented data item
  • C a reference to a class member data item
  • D the this pointer
Answer: Option C
Q93
If the ++ operator is overloaded properly, the operator++ () function returns
  • A a copy of an incremented member of a class
  • B a copy of an incremented data item
  • C a reference to a class member data item
  • D the this pointer
Answer: Option C
Q94
To overload a prefix ++ for a Number class, an appropriate function header is
  • A Number & Number :: operator ++(Number & num)
  • B Number & Number ::operator ++(int)
  • C Number & Number :: operator ++(int)
  • D This Number :: operator ++ (Number & Num)
Answer: Option C
Q95
The << operator is used for output only when
  • A it is used as a binary operator
  • B it is used as a unary operator
  • C cout is to the left
  • D you write a function to overload it.
Answer: Option C
Q96
Object-oriented programmers primarily focus on
  • A procedures to be performed
  • B the step-by-step statements needed to solve a problem
  • C objects and the tasks that must be performed with those objects
  • D the physical orientation of objects within a program.
Answer: Option C
Q97
If the <<operator has been overloaded appropriately for the class Number, and a and b are members of the Numbers class, then which statement is legal ?
  • A cout<<a;
  • B cout<<a<<b;
  • C both (a) and (b)
  • D none of these
Answer: Option C
Q98
Using an overloaded << operator for a class
  • A is the only way to display values of data members of a class
  • B works correctly only if all data members private
  • C aloows output statements within a program that uses the class to become simpler
  • D is possible only if >> operator is overloaded as well
Answer: Option C
Q99
Which of the following is the best prototype to overload the << operator for a Number class?
  • A ostream & << (ostream & out, const Number & num)
  • B friend ostream & operator <<(ostream & out const Number & num);
  • C Number & operator <<(ostream & out, const Number & num);
  • D friend ostream operator<<(const. Number & num)
Answer: Option B
Q100
If you use an = operator with classes, then
  • A you must have overloaded it
  • B you may have overloaded it
  • C you must not have overloaded it
  • D equal cannot be used with classes.
Answer: Option B
Questions and Answers for Competitive Exams Various Entrance Test