Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Dot Net Lab File

Download as pdf or txt
Download as pdf or txt
You are on page 1of 5

Written Exam:

1. What is .NET framework, and what are its key


components?
Ans: - It's like a toolbox made by Microsoft for building and
running programs. It has different tools like the Common
Language Runtime (CLR) and the Base Class Library (BCL).

2. Explain the difference between value types and


reference types in C#.
Ans: - Value types store data directly, like numbers.
Reference types store references to data, like a label for a
box that holds the data.

3. What's inheritance in C#?


Ans: - Inheritance lets a new class get stuff (properties and
actions) from another class. For example, a "car" class
could inherit things from a "vehicle" class.

4. Why use C# instead of other languages?


Ans: - C# is great because it's easy to use, helps manage
memory, has lots of built-in tools, and can work with other
languages.
5. What are abstract classes and interfaces?
Ans: - Abstract classes are like blueprints that other classes
can follow. Interfaces are like contracts that classes
promise to fulfill.

6. What's the 'using' statement in C#?


Ans: - using' helps manage things like files or connections,
making sure they're cleaned up when we're done with
them.

7. How do we deal with errors in C#?


Ans: - We use try-catch blocks to catch errors and handle
them gracefully.
Code: -
try
{
// Code that may throw an exception
}
catch (Exception ex)
{
// Handle the exception
}
8. What's LINQ, and how is it useful?
Ans: - LINQ allows querying data from different data
sources using a syntax similar to SQL within C# code.

9. What's the difference between method overloading and


overriding?
Ans: - Overloading means having multiple methods with
the same name but different jobs. Overriding means
changing how a method works in a subclass.

Viva Voice

1. What's polymorphism, and can you give an example?

Ans: - Polymorphism is when different things can be treated


the same way. Like how both a car and a bicycle can move,
even though they move differently.

2. How does C# manage memory?

Ans: - C# takes care of cleaning up memory we're not using


anymore, like picking up toys when we're done playing with
them.
3. What's encapsulation, and how does C# use it?

Ans: - Encapsulation is putting things together in a box. In C#,


we put data and the things that work with that data together
to keep things organized.

4. How do we make and use a class library in C#?

Ans: - We create a bundle of code that we can use in


different projects, making it easy to reuse our work.

5. What are access modifiers, and why are they important?

Ans: - Access modifiers help decide who can use or change


different parts of our code, like setting a lock on a door.

6. What does the 'static' keyword do in C#?

Ans: - 'Static' is like sticking something to a wall. It means


that thing belongs to the whole group, not just one person.

7. Explain the difference between '==' and '.Equals()' in C#.

Ans: - '==' is like asking if two things look the same. '.Equals()'
is like asking if two things are the same on the inside.
8. How does C# handle doing multiple things at once?

Ans: - C# can do different tasks at the same time, like talking


on the phone while cooking dinner. But sometimes, things
can get messy if we're not careful!

9. What are namespaces, and why do we use them?

Ans: - Namespaces are like folders for our code. They help
keep things organized and prevent names from clashing.

10. Why do we do unit testing in C#?

Ans: - We test small parts of our code to make sure they


work correctly, like checking each ingredient before making a
cake. It helps catch mistakes early and makes our code
better.

You might also like