# Object Oriented Programming - Functions

6:

int a =1 , b=2;

a=chg(b) ;

cout << a << b ;

If the function chg is coded as

int chg(int &x)
{

x = 10;

return ();

}

then   Functions

 A. it results in compile-time error B. it results in run time error C. it prints 112 D. it prints 111 0 Answer Report Discuss Option: D Explanation : Here the parameter passing mechanism is pass by reference. Any change done to the parameter will be reflected outside the function. So, the value of b, after the exit of the function will be 10. Click on Discuss to view users comments. Write your comments here:
7:

int a =1 , b=2;

a=chg(b) ;

cout << a << b ;

If the function chg is coded as

int chg(const int &x)

{

x=10;

return ()

};

then     Functions

 A. it results in compile-time error B. it results in run time error C. it prints 112 D. it prints 111 0 Answer Report Discuss Option: A Explanation : Here the function chg tries to change the parameter x, which is not allowed as it is declared to be a constant integer. So, the compiler gives an error. Click on Discuss to view users comments. Write your comments here:
8:

Which of the following parameter passing mechanism(s) is/are supported by C++, but not by C?

 A. Pass by value B. Pass by reference C. Pass by value-result D. All of the above Answer Report Discuss Option: B Explanation : As such C does not support pass by reference. But it can be simulated by using pointers. Click on Discuss to view users comments. Write your comments here:
9:

If a piece of code can be implemented as a macro or as an inline function, which of the following factors favour implementation as an inline function?

 A. Interacting with other components (like variables in an expression), in the correct way .. B. Flexibility to manipulate as a pointer C. Source code size D. Both (a) & (b) Answer Report Discuss Option: D Explanation : Macros do not have an address associated with them as they are processed by the pre-processor. They cannot be passed as arguments to a function, etc. Also, macros are replaced in a blind manner without any regard to the context which may result in a stupid code, like #define mul(a,b) a*b The macro call mul(a, b + 1) will be expanded as a *b+ 1, but our intention was to get a * (b+ 1 ) . Click on Discuss to view users comments. Write your comments here:
10:

Assume that the random number generating function - rand( ), returns an integer between 0 and 10000 (both inclusive). If you want to simulate the throwing of a die using this random function, use the expression

 A. rand ( ) % 6 B. rand ( ) % 6 + 1 C. rand ( ) % 5 + 1 D. none of the above Answer Report Discuss Option: B Explanation : It should randomly generate any integer between 1 and 6. rand( ) % 6 returns an integer from 0 to 5. To make it 1 to 6, we need to add 1 Click on Discuss to view users comments. Write your comments here:

Syllabus covered in this section is-

• O-O Programming Concepts , Class object instantiation
• C++ Prograinming - Elements of C++, Tokens,
• Identifters Variables and constants, data, types
• Operators, Control, statements
• Functions
• Parameter passing
• Class and objects
•  Constructors and destructors
• Templates, Exception handling

This Section covers OOPS Questions Answers .These questions can be used for the preparation of various competitive and academic exams like

• UGC NET Computer Science
• Pre PhD Entrance Exam
• DOEACC Exams
• Kendriya Vidyalaya Sangathan Entrance Test
• GATE Computer Science
• Post Graduate Computer Science Exam
•  PhD Entrance Exam
• Computer Engineering

Who can benefit

• Object Oriented Programming Questions Answers can be used by any student who is preparing for PhD entrance exam, pre PhD entrance exam, entrance exam  or any other such exam.
• Any student who is preparing for DOEACC exams can also use OOPS questions answers for preparation of his exams.
• OOPS mcq can be useful for the students who are pursuing any undergraduate or post graduate degree in computer science like BE, ME , Btech, Mtech, .BSc, MSc, BCA, MCA, BS, MS  or any other such degree
• OOPS mcq with answers and explanation can also be useful for the students who are preparing for any competitive exam or recruitment exams like GATE Computer Science, UGC NET Computer Science, Kendriya Vidyalaya Sangathan PGT exam, PSU, IES or any other such exam.
• OOPS multiple choice questions answers  can also be used by any candidate who wants to gain credits in OOPS in BS Computer science or MS Computer science,

Various Search Terms Used For This Section Are