.Net Deck 3 Flashcards

1
Q

What are C# extension methods?

A

Extension methods, as the name suggests, are additional methods. Extension methods allow you to inject additional methods without modifying, deriving or recompiling the original class, struct or interface. Extension methods can be added to your own custom class, .NET framework classes, or third party classes or interfaces.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are Interfaces?

A

A type definition similar to a class, except that it purely represents a contract between an object and its user. It can neither be directly instantiated as an object, nor can data members be defined. So, an interface is nothing but a collection of method and property declarations.

An interface contains definitions for a group of related functionalities that a class or a struct can implement. By using interfaces, you can, for example, include behavior from multiple sources in a class. That capability is important in C# because the language doesn’t support multiple inheritance of classes.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an abstract class and is this different than an interface?

A

An abstract class allows you to create functionality that subclasses can implement or override. An interface only allows you to define functionality, not implement it. And whereas a class can extend only one abstract class, it can take advantage of multiple interfaces

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Can you create an instance of an abstract class?

A

you cannot create an instance of an abstract class with the new keyword.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is inheritance?

A

Inheritance is one of the fundamental attributes of object-oriented programming. It allows you to define a child class that reuses (inherits), extends, or modifies the behavior of a parent class.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are the principles of object oriented programming?

A

Encapsulation - Mechanism of hiding of data implementation by restricting access to public methods. Instance variables are kept private and accessor methods are made public to achieve this.

Abstract - Concept or an Idea which is not associated with any particular instance. one class should not know the inner details of another in order to use it, just knowing the interfaces should be good enough.

Inheritances - Expresses “is-a” and/or “has-a” relationship between two objects. Using Inheritance, In derived classes we can reuse the code of existing super classes. based on class inheritance (using extends) or interface implementation (using implements).

Polymorphism - One name many forms. It is further of two types — static and dynamic. Static polymorphism is achieved using method overloading and dynamic polymorphism using method overriding.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Write out an example class diagram (a diagram showing how several classes are related) for the objects described description

A

Include Classes for:

  • Base person class
  • Employee class
  • Manager class
  • Robot class

Include an interfaces for:

  • “People”
  • “Robots”
  • An interface that both implement

Include an example of an abstract method and an abstract class

Be sure to have an example of how you leverage inheritance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are Generics in .Net

A

Generics are classes, structures, interfaces, and methods that have placeholders (type parameters) for one or more of the types that they store or use.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Why are Generics so important?

A

Generics in C# is its most powerful feature. It allows you to define the type-safe data structures. This out-turn in a remarkable performance boost and high-grade code, because it helps to reuse data processing algorithms without replicating type-specific cod

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is IEnumerable and what significance does it hold?

A

IEnumerable is an interface that allows you to loop over an entire collection.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly