Consider the following code and predict the output:

public class Car
{
        public string carModel;
        public string carColor;
        public Car(string carModel, string carColor)
        {
            this.carModel = carModel;
            this.carColor = carColor;
        }

        public void CarDetails()
        {
            Console.WriteLine("Car Model :{0} , Car Color :{1}",carModel,carColor);   
        }
}
    
class Program
{
        static void Main(string[] args)
        {
            Car carObj1 = new Car("Audi", "Black");
            Car carObj2 = carObj1;
            Car carObj3 = carObj2;

            Car[] carObjArray = { carObj1, carObj2, carObj3 };

            for(int i = 0; i < carObjArray.Length; i++)
            {
                if(carObjArray[i] != null)
                {
                    carObjArray[i].CarDetails();
                    carObjArray[i] = null;
                }
            }
        }
}

Select the output from the following options:

a. Car Model :Audi , Car Color :Black

b. Car Model :Audi , Car Color :Black
Car Model :Audi , Car Color :Black

c. Car Model :Audi , Car Color :Black
Car Model :Audi , Car Color :Black
Car Model :Audi , Car Color :Black

d. Runtime Error

Option a

Option b

Option c

Option d

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