What will be the value of the salary after the below given code is executed?

public class Employee
{
     private int salary;
     public int Salary
     {
         private get
         {
             return salary;
         }
         set
         {
             salary = value;
         }
     }
     public Employee(int salary)
     {
         this.Salary = salary;
     }
}
class Program
{
     static void Main(string[] args)
     {
         Employee objCC = new Employee(10000);
         objCC.Salary++;
     }
        
}

10000

10001

Compilation Error:The property cannot be used in this context because the get accessor is inaccessible

10002

Verified Answer
Correct Option - c

To get all Basic CSharp Programming Assessment Exam questions Join Group https://bit.ly/infy_premium_group

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