Interviewer
Interviewer
Candidate:
Thank you for the question.
The key difference between Object-Oriented Programming (OOP) languages and other
paradigms, such as procedural or functional programming languages, lies in how they
structure and manage code.
OOP languages—like Java, C++, Python (when used in OOP style), and C#—are based on the
concept of "objects." These objects encapsulate both data (attributes) and behaviors
(methods), which promotes modularity, reusability, and scalability. The core principles of
OOP include encapsulation, inheritance, polymorphism, and abstraction.
On the other hand, procedural languages like C or early versions of BASIC follow a linear
step-by-step approach and focus more on functions and procedures rather than objects.
Data and functions are treated separately, which can make large codebases harder to
maintain.
Candidate:
Thank you for the question.
A class is a blueprint or template for creating objects. It defines the structure and
behavior that the objects will have. It includes properties (also known as attributes or
fields) and methods (functions).
An object, on the other hand, is an instance of a class. It is the actual entity that
occupies memory and performs actions defined in the class.
Class = Definition
So, multiple objects can be created from a single class, each with its own data but sharing
the same structure and behavior.
Interviewer: What is the .NET Framework?
Candidate:
Certainly.
1. Common Language Runtime (CLR): This is the execution engine that handles running
applications. It provides essential services such as memory management, exception
handling, garbage collection, and security.
2. Framework Class Library (FCL): A large collection of reusable classes, interfaces, and
value types that provide functionality for everything from file I/O to database access,
web services, and user interface development.
Candidate:
Thank you for the question.
The difference between List<T> and IEnumerable<T> in C# lies primarily in their capabilities
and intended usage:
1. Definition:
2. Functionality:
IEnumerable<T>:
o Allows iteration only.
List<T>:
o You're working with large datasets and want deferred execution (like with
LINQ).
Example:
csharp
CopyEdit
numberList.Add(4);
Candidate:
Certainly. The .NET ecosystem has evolved significantly over time, and it can be broadly
divided into three phases: .NET Framework, .NET Core, and the unified .NET (5 and beyond)
platform.
Key versions:
Platform: Windows-only.
Introduced: 2016
Key versions:
o .NET Core 3.0 – 3.1: Supported desktop apps (WPF, WinForms) and Blazor.
.NET 5 (2020): First unified version combining .NET Core and parts of the .NET
Framework.
.NET 6 (2021): Long-Term Support (LTS) version with improved performance, Hot
Reload, MAUI (multi-platform UI).
Candidate:
Thank you for the question.
Although the names sound similar, Java and JavaScript are completely different languages
in terms of syntax, purpose, and runtime environment.
Key Differences:
Object-oriented programming
Type Scripting language primarily for web
language
Interviewer: Can you explain the difference between abstract classes and interfaces in C#?
Candidate:
Certainly! Both abstract classes and interfaces are used in object-oriented programming
(OOP) to define contracts for classes. However, they have different purposes and
capabilities. Here's a detailed explanation of each:
1. Abstract Class:
An abstract class is a class that cannot be instantiated directly. It allows you to define
methods that must be implemented by derived classes, while also providing a base
implementation of some methods. Abstract classes are used when there is a common base
class for a group of related classes, but some methods still need to be implemented by the
derived classes.
Key Features:
o A class can inherit from only one abstract class (single inheritance).
Use Case:
Use an abstract class when you want to define common functionality across several
classes, but still leave some functionality for the derived classes to implement.
Example:
csharp
CopyEdit
Console.WriteLine("Animal is sleeping.");
Console.WriteLine("Bark!");
2. Interface:
An interface defines a contract that classes must follow. It can only contain method
signatures (no implementation), properties, events, or indexers, and any class that
implements an interface must provide an implementation for all of its members.
Key Features:
Use Case:
Use an interface when you want to define a contract that any class can implement,
without enforcing an inheritance hierarchy.
Example:
csharp
CopyEdit
{
public void MakeSound()
Console.WriteLine("Bark!");
}
1. Super Key
A super key is any combination of columns that uniquely identifies a row in a table.
It can include extra attributes that are not necessary for uniqueness.
Example:
sql
CopyEdit
Super Keys:
- {StudentID}
- {Email}
- {StudentID, Name}
2. Candidate Key
Example:
sql
CopyEdit
3. Primary Key
A primary key is one of the candidate keys chosen to uniquely identify records in a
table.
Example:
sql
CopyEdit
4. Unique Key
A unique key also ensures uniqueness, but allows one NULL (in most DBMSs like
MySQL).
Example:
sql
CopyEdit
UNIQUE (Email)
5. Foreign Key
A foreign key is a column (or set of columns) that references the primary key in
another table.
Example:
sql
CopyEdit