1.

Can main() function be made private?(a) Yes, always(b) Yes, if program doesn’t contain any classes(c) No, because main function is user defined(d) No, neverThis question was posed to me during an online interview.My question is taken from Private Member Functions in portion Member Functions & its Types of Object Oriented Programming

Answer»

Correct choice is (d) No, never

To explain: The reason GIVEN in option “No, because main function is USER defined” is wrong. The proper reason that the main function should not be private is that it should be ACCESSIBLE in whole PROGRAM. This MAKES the program flexible.



Discussion

No Comment Found

Related InterviewSolutions