1.

Which access specifier should be used in a class where the instances can’t be created?(a) Private default constructor(b) All private constructors(c) Only default constructor to be public(d) Only default constructor to be protectedThe question was asked during an online exam.The query is from Access Specifiers topic in chapter Access Specifiers of Object Oriented Programming

Answer»

Right OPTION is (b) All private constructors

The BEST EXPLANATION: All the constructors must be MADE private. This will restrict the instance of class to be made anywhere in the program. Since the constructors are private, no instance will be ABLE to call them and hence won’t be allocated with any memory space.



Discussion

No Comment Found

Related InterviewSolutions