GATE-Programming Methodology Questions and Answers

Practice Mode
Showing 10 of 105 questions
Q51
You can bestow friendship on
  • A a function that is a meber of another class
  • B several functions that are members of another class
  • C all functions that are members of another class
  • D all of these
Answer: Option D
Q52
You can bestow friendship on all members of another class by
  • A making each function a friend
  • B making a friend of the entire class
  • C either( a) or (b)
  • D none of these
Answer: Option C
Q53
You need to display two private data members from one object of a class. You would
  • A create a member function to preserve data hiding
  • B create a friend function to implement object oriented programming
  • C create both friend and member functions fo give the programmer a choice
  • D not create a function, but just display the data members directly.
Answer: Option A
Q54
A function that can access private members of a class, even though it is not a member of the class itself, is
  • A a friend
  • B an inline function
  • C a private function
  • D never allowed in object-oriented programming.
Answer: Option A
Q55
Select the correct statement of the following ?
  • A When you create a function, you can declare it to by a friend function.
  • B When you create a friend function, you must include the friend keyword in the function header.
  • C nonscallar types
  • D cryptic code
Answer: Option B
Q56
Select the correct statement of the following ?
  • A A class declaration must state which functions will be its friends
  • B Afriend function must declare to which classes it will be a friend
  • C both (a ) and (b)
  • D none of these
Answer: Option A
Q57
A function can
  • A be granted friendship by a class you create
  • B declare itself to be a friend of you class
  • C grant friendship to alother function
  • D grant friendship to a class create
Answer: Option A
Q58
When a nonmember function needs to refer to instances of two different classes, then
  • A only one class may grant friendship to the function
  • B both classes must grant friendship to the funcion
  • C either class may grant friendship to the function
  • D neigher class may grant friendship to the function
Answer: Option B
Q59
When a nonmber function needs to refer to instances of two different classes, then you must
  • A store the classes in separate files
  • B meke the classes friends of the one another
  • C make a forward reference to one of the classes
  • D make a forward reference to both of the classes
Answer: Option C
Q60
A forward reference
  • A defines a class
  • B eliminates the need to define a class
  • C acknowledgtes the existence of a a class
  • D is illegal in object-oriented programming.
Answer: Option A
Questions and Answers for Competitive Exams Various Entrance Test