GATE-Programming Methodology Questions and Answers

Practice Mode
Showing 10 of 105 questions
Q81
If an operator is normally defined to be only unary, then you
  • A may overlaod it to be binary
  • B must overload it to be binary
  • C may not overload it to be binary
  • D may not overload it
Answer: Option D
Q82
When you overload an operator for use with your classes, you
  • A must use the overloaded operator for the usual purpose
  • B should use the overloaded operator for the usual purpose
  • C may not use the overloaded operator for the usual purpose
  • D may not overload operators that have a usual purpose
Answer: Option C
Q83
You overload an operator by naming it a
  • A variable
  • B built-in-type
  • C function
  • D class
Answer: Option C
Q84
Assuming you have properly overloaded the ! operator for a Number class, and that a and b are two members of the Number class, which expression is legal?
  • A !a
  • B b!
  • C a!b
  • D all of these
Answer: Option A
Q85
To perform multiple arithmetic operations in a single statement, overloaded operator functions should return
  • A void
  • B a copy of the values passed to them
  • C an object of the class type
  • D address of the function
Answer: Option C
Q86
Which of the following is the best function prototype for an overloaded .......... for a Number class ?
  • A number operator-(const Number & num);
  • B Number & operator-(int num);
  • C int Number (operator-();
  • D void operator-(Number & num);
Answer: Option A
Q87
The programming language feature that allows the same operation to be carried out differently depending on the object is
  • A polymorphism
  • B inheritance
  • C allocation
  • D mangling
Answer: Option A
Q88
Specifically, overloading involves
  • A one function with a variety of arguments
  • B multiple functions defined with the same name
  • C one function with multiple names
  • D multiple functions with different names.
Answer: Option B
Q89
A usable function header for an overloaded operator for a Number class is
  • A Number operator >>(istream & in, Number & num)
  • B intream & operator>>(istream & in, const Number & num)
  • C friend instream & operator>>(instream & in, Number & num)
  • D istream & operator>>(istream & in, Number & num)
Answer: Option C
Q90
If the >> operator is overloaded properly for use for input with a number class, and a and b are member of the Number class, which of the following statement is allowed ?
  • A cin >> a;
  • B cin >> a,b
  • C both (a) and (b)
  • D None of these
Answer: Option A
Questions and Answers for Competitive Exams Various Entrance Test