Post Details

.NET Interview Questions Asked in Cognizant Walk-in Drive, Indore 2025

np

Tue , Mar 04 2025

np
.NET Interview Questions

.NET Interview Questions Asked in Cognizant Walk-in Drive, Indore 2025

I am talking about my interview experience during the Cognizant walk-in drive for .NET Developer and Lead positions in Indore.

Interview Process:

  1. Entry and Token System:
    • Upon arrival, we were given tokens at the campus and directed to get coupon codes from a designated place.
    • These coupon codes included the URL for the registration form, which was a Microsoft-based survey form. We needed to scan and fill out this form to apply for the positions.
  2. Waiting Area:
    • After filling out the form, we entered the office with our coupon codes.
    • There were around 500 candidates present, and we continuously monitored announcements for our names to be called for the interview.
  3. Interview Rounds:
    • There were two interview rounds conducted on the company premises.
    • Some candidates had face-to-face interviews, while others participated in virtual interviews.
    • During the virtual interviews, we were provided with laptops on-site.

Interview Questions and Answers:

  • Introduction: The first question was to introduce ourselves, considering our background and technical skills.
  • Technical Questions:
    • Difference between var and dynamic
    • // var: The type is determined at compile time
      var number = 10; // 'number' is of type int
      
      // dynamic: The type is determined at runtime
      dynamic obj = 10;
      obj = "Hello"; // 'obj' is now of type string
    • Explanation of ref and out keywords
    • void SampleRef(ref int x)
      {
          x = 20;
      }
      
      void SampleOut(out int x)
      {
          x = 30;
      }
      
      int a = 10;
      SampleRef(ref a); // a is now 20
      
      int b;
      SampleOut(out b); // b is now 30
    • Explanation of delegates and their types
    • public delegate void DisplayMessage(string message);
      
      public class Program
      {
          public static void Main()
          {
              DisplayMessage dm = ShowMessage;
              dm("Hello, Delegate!");
          }
      
          public static void ShowMessage(string message)
          {
              Console.WriteLine(message);
          }
      }
    • Discussion on design patterns and SOLID principles
    • // SOLID Principles:
      // S: Single Responsibility Principle
      // O: Open/Closed Principle
      // L: Liskov Substitution Principle
      // I: Interface Segregation Principle
      // D: Dependency Inversion Principle
    • Explanation of the Liskov Substitution Principle
    • public class Bird
      {
          public virtual void Fly() { Console.WriteLine("Flying"); }
      }
      
      public class Sparrow : Bird { }
      
      public class Ostrich : Bird
      {
          public override void Fly()
          {
              throw new InvalidOperationException("Ostriches cannot fly");
          }
      }
    • Difference between varchar and char data types in SQL
    • // varchar: Variable-length character data
      // char: Fixed-length character data
    • Explanation of object creation models in .NET
    • // Default constructor
      MyClass obj1 = new MyClass();
      
      // Parameterized constructor
      // Parameterized constructor
      MyClass obj2 = new MyClass(10);
      
      // Singleton pattern
      public sealed class Singleton
      {
          private static readonly Singleton instance = new Singleton();
      
          private Singleton() { }
      
          public static Singleton Instance
          {
              get { return instance; }
          }
      }
      
    • Problem-solving questions related to design patterns
    • // Singleton Pattern Example
      public sealed class Singleton
      {
          private static readonly Singleton instance = new Singleton();
      
          private Singleton() { }
      
          public static Singleton Instance
          {
              get { return instance; }
          }
      }
      
    • Writing a program to reverse a string
    • public class Program
      {
          public static void Main()
          {
              string str = "Hello, World!";
              string reversedStr = ReverseString(str);
              Console.WriteLine(reversedStr);
          }
      
          public static string ReverseString(string str)
          {
              char[] charArray = str.ToCharArray();
              Array.Reverse(charArray);
              return new string(charArray);
          }
      }
      
    • Writing a program to remove duplicate entries
    • public class Program
      {
          public static void Main()
          {
              int[] numbers = { 1, 2, 2, 3, 4, 4, 5 };
              int[] distinctNumbers = RemoveDuplicates(numbers);
              Console.WriteLine(string.Join(", ", distinctNumbers));
          }
      
          public static int[] RemoveDuplicates(int[] numbers)
          {
              return numbers.Distinct().ToArray();
          }
      }
      

Feedback:

The interview went well, but I haven't received any feedback yet. They mentioned that feedback would be shared in the upcoming days, and I am still waiting for it.

Thanks, everyone, for reading about my interview experience and the process involved.

Leave a Reply

Please log in to Comment On this post.