C# Flashcards
What does async and await mean?
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.
What is MVC?
It’s an architectural design pattern that separates an application into three main logical components; Model, View, Controller.
What are access modifiers/ specifiers?
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.
What are all the types of access modifiers?
Public Private Internal Protected Protected Internal
What is a public and private access modifier?
Private members are available only within the containing type whereas public members are available anywhere. There’s no restriction for public members.
What is a protected access modifier?
Protecting members are available within the containing type and to the types that are derived from the containing type.
What is an internal access modifier?
Internal access modifiers are available anywhere within the containing assembly.
What is a protected internal access modifiers?
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.
What are namespaces and why do we use them?
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.
What are constructors?
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.
What is dependency injection?
Its a design pattern where an object receives other objects that it depends on.
Why do we use dependency injection?
Makes our code more maintainable.
What is a class?
Can be described as the blueprint of a specific object. The class is a blueprint from which the individual objects are created.
What is an object?
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.
What is an abstract class?
A special type of class that can be instantiated. It’s designed to be inherited by subclasses. The subclass must override its method.
What is a concrete class?
A simple class with members such as methods and properties.
What is a sealed class?
Can not be inherited by any other class.
What is a partial class?
Allow us to define a class on multiple files.
What is a static class?
Basically the same as a non-static class but a static class can’t be instantiated. All the members of the class are static.
What are methods?
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.
What does the static keyword mean?
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
What is data binding?
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.
What are virtual methods?
Virtual methods have an implementation and provide the derived classes with the option of overriding it.
What is a heap and stack?
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.
What is .NET core?
It’s a free open source cross platform software used for building websites, services, and console applications.
What is ASP.NET?
It’s a web application development framework.
What does MVC do?
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.
What is an API?
Application programming interface. It’s a set of commands that allow our applications to interact with our data or other application’s data.
What are the http methods?
HttpGet (Read)
HttpPut (Update)
HttpPost (Edit)
HttpDelete (Delete)
What is authentication and authorization?
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.
What is LINQ?
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)
What are the CRUD operations?
Creat
Read
Update
Delete
What is the garbage collector?
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.
What are the two types of memory allocation?
Stack and heap memory
What is multithreading?
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
Method overriding vs method overloading?
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.
What is exception handling?
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.