15 Technical Interview Questions for Freshers in MNCs: Technical interview questions for a fresher applying for a Software Developer Engineer position with skills in C and .NET Development, Web Development and APIs, Frontend Development, Testing and DevOps, and C++ in MNCs like TCS, Wipro, Infosys, Siemens, and others.
C# and .NET Development
1. What are the main principles of Object-Oriented Programming (OOP)? Can you explain each principle with an example in C#?
Answer:
OOP Principles:
Polymorphism: The ability to present the same interface for different underlying forms (data types). Example: A method Draw(Shape s)
can take any shape (Circle, Rectangle).
Encapsulation: Bundling data and methods that operate on that data within a single unit (class). Example: A Car
class that has properties like Color
and methods like Drive()
.
Abstraction: Hiding complex implementation details and showing only the essential features. Example: An abstract class Shape
with a method Draw()
that derived classes implement.
Inheritance: A mechanism to create a new class using properties and methods of an existing class. Example: A SportsCar
class inheriting from Car
.
2. Can you describe what a Design Pattern is and provide examples of two common design patterns used in C#?
Answer
Design Patterns:
Observer: A way to notify multiple objects about state changes. Example: A NewsPublisher
that notifies all subscribed Subscribers
when news is published.
Singleton: Ensures a class has only one instance and provides a global access point. Example: A logging class that manages logs in a single instance.
3. What are some key differences between an interface and an abstract class in C#? When would you choose one over the other?
Answer:
Interface vs. Abstract Class:
Abstract Class: Can contain both abstract methods and implemented methods. Use when classes share common behavior but may also have unique methods.
Interface: Can only contain method signatures (no implementation). Use when multiple classes might implement the same methods differently.
4. How do you handle exceptions in C#? Can you provide an example of how to implement a try-catch block?
Answer
Exception Handling in C#:
try
{
// Code that may throw an exception
int result = 10 / 0;
}
catch (DivideByZeroException ex)
{
Console.WriteLine("Cannot divide by zero: " + ex.Message);
}
finally
{
// Code that runs regardless of exception
Console.WriteLine("Execution completed.");
}
5. Explain what the .NET Framework is. What are the differences between .NET Framework, .NET Core, and .NET 5/6?
Answer:
.NET Framework:
.NET 5/6: Unifies .NET Core and .NET Framework into a single platform for all types of applications.
.NET Framework: A platform for building Windows applications.
.NET Core: A cross-platform version of .NET for building cloud-based applications.
Web Development and APIs
6. What is a RESTful API? Can you explain the principles of REST and how you would design a RESTful service in C#?
Answer
RESTful API:
REST stands for Representational State Transfer. It uses standard HTTP methods (GET, POST, PUT, DELETE) for CRUD operations and is stateless. Example: Designing a GET /users
endpoint to retrieve users.
7. How do you connect a C# application to a SQL database? Can you describe the process and the classes you would use?
Answer:
Connecting C# to SQL:
- Use ADO.NET or Entity Framework. Example:
using (SqlConnection conn = new SqlConnection(connectionString))
{
conn.Open();
SqlCommand cmd = new SqlCommand("SELECT * FROM Users", conn);
SqlDataReader reader = cmd.ExecuteReader();
}
8. What is the purpose of using Entity Framework in a .NET application? Can you explain how it simplifies database operations?
Answer:
Entity Framework:
It is an ORM (Object-Relational Mapper) that simplifies data access by allowing developers to work with databases using C# objects rather than SQL queries.
9. How do you ensure the security of a web application? What measures would you implement to protect against common vulnerabilities?
Answer:
Web Application Security:
Implement HTTPS, input validation, output encoding, and security headers. Use authentication and authorization mechanisms to protect sensitive data.
Frontend Development
10. Can you describe the role of Angular in building web applications? What are some of its key features?
Answer:
Role of Angular:
Angular is a platform for building web applications using TypeScript. Key features include two-way data binding, dependency injection, and a modular architecture.
11. What is the difference between Angular components and services? How do they interact in an Angular application?
Answer
Components vs. Services:
Services: Share data and logic across components. They are used for operations like fetching data from APIs.
Components: Control views and UI. They manage data binding and user interactions.
12. How do you handle state management in Angular applications? Can you discuss a few common strategies?
Answer:
State Management in Angular:
Strategies include using services for shared state, the Redux pattern, or libraries like NgRx for complex state management.
Testing and DevOps
13. What is unit testing, and why is it important in software development? Can you explain how you would write a unit test in C#?
Answer:
Unit Testing:
- Unit testing verifies that individual components work as expected. Example using NUnit:
[Test]
public void TestAdd()
{
Assert.AreEqual(4, Add(2, 2));
}
14. What tools or frameworks have you used for automated testing in your applications? Can you describe your experience with one of them?
Answer:
Testing Tools:
Common tools include NUnit, xUnit, and Moq for mocking. Experience can include writing test cases to ensure code quality.
15. Can you explain what DevOps is and how it integrates with software development? What tools have you used in the DevOps lifecycle?
Answer:
DevOps:
DevOps is a culture that integrates development and operations to shorten the development lifecycle. Tools include Jenkins for CI/CD, Docker for containerization, and Kubernetes for orchestration.
Bonus Question (C++ Knowledge)
16. Have you worked with C++? Can you describe how memory management differs between C# and C++?
Answer:
Memory Management Differences:
C++: Developers manually manage memory using new
and delete
. This allows for fine control but requires careful management to avoid leaks.
C#: Automatic garbage collection manages memory.
These questions cover a range of topics that are likely to be relevant for the position, including C# development, web APIs, frontend frameworks, testing, and DevOps practices. Good luck with your interview preparation!