Answered Questions

  • is it possible to inherit a class that has only private constructor?

    Sujit

    • Feb 18th, 2019

    Nope. We cant inherit a class if it has Private constructor.

    Vikas Kumar Bhatnagar

    • Aug 14th, 2018

    We cant inherit the abstract class and when we declared a class as abstract and define the private constructor .
    Following compilation error:
    Cannot create an instance of the abstract class or interface Singleton.
    Singleton.Singleton() is inaccessible due to its protection level

  • How do you refer parent classes in C#

    A) SuperB) ThisC) Base

    Yazdani

    • Mar 20th, 2006

    Super : Super is used to Refer the Base Class in JAVAThis  : This is used to Refer the Current or Child Class in C#Base  : Base is used to Refer The Parent or Base Class

    Biswa Prakash Rath

    • Mar 13th, 2006

    C) BaseWhile Base is used to refer parent class, This is used to identify the current class in C#.

  • If A.equals(B) is true then A.getHashcode & B.getHashCode must always return same hash code

    A) TrueB) False

    ViBi

    • Apr 19th, 2015

    Two objects that are equal return hash codes that are equal. However, the reverse is not true: equal hash codes do not imply object equality, because different (unequal) objects can have identical hash codes

    https://msdn.microsoft.com/en-us/library/system.object.gethashcode%28v=vs.110%29.aspx

    regex

    • Apr 7th, 2015

    It is clearly false. Proof: "c class MyClass { public int _id; public MyClass(int id) { _id = id; } public bool Equals(MyC...

  • It is perfectly legitimate to throw exceptions from catch and finally blocks

    A) TrueB) False

    sathya

    • Aug 30th, 2006

    There is no need to avoid throwing exceptions from finally block as a matter from any parts of the code.  The main idea of throwing exception is to inform caller of this block of the code about t...

    Pan

    • Jan 31st, 2006

    True, it is legitimate to throw exception from finally block but it should be avoided as fas as possible.

  • Constructors can not be static ?

    Sivavt

    • Mar 25th, 2012

    Yes, there can be a static constructor. It will be at class level & executed just once. It is totally in run-times control & not sure of when this will be executed. But, it is assured that it will be executed before creating instance of the class.

    Aashish Chachra

    • Mar 2nd, 2012

    A class can have only one static constructor. Static constructor can not have any parameter. Static constructor cannot have any access specifier, not even private. It is used to initialize the static ...