What is the output of the following code snippet?

public class Emp
{
    static Emp()
    {
        Console.WriteLine("Emp +" "); 
    }
}


public class HR : Emp
{
    public HR()
    {
        Console.WriteLine("HR" + " ");
        Emp emp = new Emp();
    }
    public static void Main()
    {
        HR hr = new HR();
    }
}

 

Emp HR Emp
HR
Emp HR
Compilation Error: "Cannot call static constructor from non-static constructor"
Verified Answer
Correct Option - c

To get all Infosys Certified CSharp Programmer Exam questions Join Telegram Group https://bit.ly/infy_premium_group

Telegram

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in

Updated on Tue, 1 Jul 2025