Answered Questions

  • Which of the following statement is invalid with regards to constructor

    A) Constructors should have the same name as class nameB) Constructors have to be public so that class can be instantiatedC) Constructors can not be overloadedExplanation: Constructors can be overloaded with different parameters

    S.M.Sadrul Islam Asif

    • Feb 5th, 2015

    B,We can have private constructor.

    Manish

    • Jan 7th, 2015

    B&C are wrong. B : In case of singleton we create a private constructur for class. A static method in this class calls the constructor nad returns the class instance. C : We can have any number of co...

  • Which of the following statements is not true for interfaces

    A) Interface definitions does not have implementationB) Interfaces must be declared as publicC) Interfaces can be instantiatedD) Interface does not have constructorsExplanation: Interfaces can only be implemented by inheriting and they can not be instantiated

    Saurabh

    • Dec 24th, 2014

    Both B & C are wrong. Interfaces can be private and in that case public classes cannot inherit them. You can define it within a class. C is wrong as we cannot create an instance of the interface.