C# Flashcards

1
Q

What does async and await mean?

A

They are code markers, that tell us where the application should continue once the task is complete.

Await, wait here until this line of code is complete.

In a synchronous application if code is blocked then the entire application waits which takes more time.

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

What is MVC?

A

It’s an architectural design pattern that separates an application into three main logical components; Model, View, Controller.

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

What are access modifiers/ specifiers?

A

They’re accessibility levels, all types and members have accessibility levels, they control whether they can be used from other code in the assembly or other assemblies.

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

What are all the types of access modifiers?

A
Public
Private 
Internal
Protected 
Protected Internal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a public and private access modifier?

A

Private members are available only within the containing type whereas public members are available anywhere. There’s no restriction for public members.

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

What is a protected access modifier?

A

Protecting members are available within the containing type and to the types that are derived from the containing type.

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

What is an internal access modifier?

A

Internal access modifiers are available anywhere within the containing assembly.

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

What is a protected internal access modifiers?

A

Can be accessed anywhere within the assembly in which it is declared or form within a derived class in another assembly. It is a combination of protected and internal.

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

What are namespaces and why do we use them?

A

They’re used to organize code into logical groups and to prevent name collisions that can occur especially when your code base includes multiple libraries.

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

What are constructors?

A

Constructors are special types of methods of a class that automatically get executed whenever we create an instance (object) of that class. The constructors are responsible for two things. Object initialization and memory allocation.

Note: The constructor name must match the class name and it cannot have a return type. The constructor is called when the object is created. All classes have constructors by default, if you do not create a class constructor yourself, c# creates one for you. However, then you are not able to set initial values for those fields.

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

What is dependency injection?

A

Its a design pattern where an object receives other objects that it depends on.

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

Why do we use dependency injection?

A

Makes our code more maintainable.

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

What is a class?

A

Can be described as the blueprint of a specific object. The class is a blueprint from which the individual objects are created.

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

What is an object?

A

An object is an instance of a class. Can be considered as a thing that can perform activities. The set of activities that the object performs defines the object’s behavior.

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

What is an abstract class?

A

A special type of class that can be instantiated. It’s designed to be inherited by subclasses. The subclass must override its method.

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

What is a concrete class?

A

A simple class with members such as methods and properties.

17
Q

What is a sealed class?

A

Can not be inherited by any other class.

18
Q

What is a partial class?

A

Allow us to define a class on multiple files.

19
Q

What is a static class?

A

Basically the same as a non-static class but a static class can’t be instantiated. All the members of the class are static.

20
Q

What are methods?

A

A code block that contains a series of statements. A program causes the statements to be executed by calling the method. In C#, every executed instruction is performed in the context of a method.

21
Q

What does the static keyword mean?

A

Only one instance of the members exist for a class. Static variables are used for defining constants because their values can be retrieved by invoking a the class without creating an instance of it.

Ex: Console.WriteLine

22
Q

What is data binding?

A

Process that establishes a connection between the app UI and the data it displays. If everything is connected properly, the when the data changes is value, the elements that are bound to the data will also reflect changes automatically.

23
Q

What are virtual methods?

A

Virtual methods have an implementation and provide the derived classes with the option of overriding it.

24
Q

What is a heap and stack?

A

There are two types of memory allocation; stack and heap memory.

Stack is used for static memory allocation and heap for dynamic memory allocation both stored in the computer’s ram.

Object types need dynamic memory while primitive data types need static memory.

Primitive types: int, bool, float, short, double, object reference

Objects and strings are stored on the heap. But their reference pointer is stored on the stack (value is null) and points to the heap.

It will clear all memory on the stack once the method has been executed (in a LIFO approach). Garbage collector cleans up the heap.

25
Q

What is .NET core?

A

It’s a free open source cross platform software used for building websites, services, and console applications.

26
Q

What is ASP.NET?

A

It’s a web application development framework.

27
Q

What does MVC do?

A

Controller: is the component that receives the incoming HTTP request and handles it. Controller also selects a view to render the domain data. When selecting the view it’s the responsibility of the controller to pass the model data

Model: contains a set of classes to represent the domain data as well as logic to manage the data (services, interface folders).

View: creates the user interface with data from the model.

28
Q

What is an API?

A

Application programming interface. It’s a set of commands that allow our applications to interact with our data or other application’s data.

29
Q

What are the http methods?

A

HttpGet (Read)
HttpPut (Update)
HttpPost (Edit)
HttpDelete (Delete)

30
Q

What is authentication and authorization?

A

Authentication: Ensures and confirms a user’s identity. Logging in.

Authorization: determines whether the user has access to a particular resource or not.

Authentication happens first, then authorization.

31
Q

What is LINQ?

A

Part of a language but not a complete language. Provides common query syntax which allows us to query the data from various data sources (database, xml documents)

32
Q

What are the CRUD operations?

A

Creat
Read
Update
Delete

33
Q

What is the garbage collector?

A

The garbage collector serves as an automatic memory manager. The garbage collector manages the allocation and release of memory for an application.

When there isn’t enough memory to allocate an object, the GC must collect and dispose of garbage memory to make memory available for new allocations.

34
Q

What are the two types of memory allocation?

A

Stack and heap memory

35
Q

What is multithreading?

A

Multithreading in C# is a process in which multiple threads work simultaneously. It is a process to achieve multitasking. It saves time because multiple tasks are being executed at a time

36
Q

Method overriding vs method overloading?

A

Overloading is when you have multiple methods in the same scope, with the same name but different signatures.

Overriding is a principle that allows you to change the functionality of a method in a child class.

37
Q

What is exception handling?

A

It’s the process to handle runtime errors. We perform exception handling so that normal flow of the application can be maintained even after runtime errors.

If we don’t handle the exception it prints an exception message and terminated the program.