C#/.NET Technical Questions Flashcards

1
Q

What is a Class in C#?

A

A class is a blueprint for an object that defines what that object will look like. Think of it like a cookie cutter. You define classes with properties and methods, and then you can instantiate them as many times as you want (i.e. using the cookie cutter to make as many cookies as you want.)

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

What are Class Members?

A

Instance members - accessible from an object
Static members - accessible from the class

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

What is an Object?

A

An object is an instance of a class
Ex: JohnObject has a name, age, height, weight, can perform methods such as run, walk, talk, sleep, eat

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

Where in C# is it appropriate to use Camel Case?

A

Camel Case is appropriate when naming private or internals fields such as parameters and variables

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

What is an Access Modifier and why are they used?

A

It is a way to control access to a class and/or its members, and it creates safety in our programs, preventing bugs in our code.
In C# they include:
1. Public
2. Private
3. Protected
4. Internal
5. Protected Internal

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

What is OOP (Object Oriented Programming in relation to C#/.NET?

A

It’s a style of programming that uses objects to represent data in your code.
It’s four main concepts are:
* Encapsulation
* Inheritance
* Abstraction
* Polymorphism

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

What is Encapsulation?

A

Encapsulation refers to hiding data in private fields so that it’s harder to mess up.

Example: let’s imagine we had a class called Cohort that contained a list of students. We ONLY want to add a student to our list IF a) the cohort has less than 20 people and b) the student is approved for admission. If we make our list of students public, any developer in our code base can add any student, even if they don’t meet those conditions. If we make it private (i.e. if we ENCAPSULATE it in our Cohort class), we can write a public method that will add a student to a class only if our two conditions are met.

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

What is Inheritance?

A

Inheritance refers to inheriting fields and methods from one class to another.
Base Class(parent) - the class being inherited from.
Derived Class(child) - the class that inherits from another class
For example, we might make a Person base class and have Student and Instructor inherit from it so that we don’t have to write out all the same properties twice. This cuts down on the code we have to write and makes our code more reusable.

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

What is Abstraction?

A

It refers to a simple interface that does a complicated thing.

Example: in Entity Framework, we can write _context.Orders.ToList() and get a list of all our orders. Under the hood, Entity is writing a SQL query, reading the raw data, mapping it to our Order model, and adding it to a list. (We did all these things in ADO.NET!) We don’t have to see or think about all of that complexity, because Entity framework has abstracted it away.

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

What is Polymorphism?

A

Polymorphism means “many forms”. In OOP languages, classes and methods can occur in many forms. Example one: a Parrot class and a Toucan class can both implement a Bird interface in different ways, which means that the Bird interface occurs in many forms. A controller in ASP.NET can have two methods called Create, one that loads a create form and one that accepts data from a Create form. The create method occurs in many forms.

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

What is an ERD and why are they helpful?

A

ERD stands for entity relationship diagram. ERDs map the relationships between your tables in a database. They help the whole team get on the same page with data structure and provide a point of reference throughout the project.

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

What is the MVC design pattern?

A

MVC stands for Model, View Controller. We build MVC applications in ASP.NET, but a lot of frameworks use MVC. Models represent the tables in your database, views present that data to the user, and controllers are in charge of controlling the signal flow through the application– in our case, they accept HTTP requests from a client, query the database, map the data to our models, and then send it to the views

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

What experience do you have with SQL?

A

We used T-SQL (Microsoft’s specific flavor of SQL) with SQL Server. We primarily used SQL in tandem with ADO.NET, which is a database tool in .NET core and allowed us to write complex SQL queries to load data into our web applications.

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

What is RESTful API?

A

RESTful stands for Representational State Transfer. Generally, this means that the API is in charge of representing the current ‘state’ of the database to the client. (The state of the database just means what data is in there at the time of the request.) A RESTful API sends data back as JSON. (Some other API architectures, like SOAP, send data back as XML.)

There are some technical rules that an API is SUPPOSED to fulfill in order to be considered truly RESTful, but very few actually fulfill all of them. The rules are from a guy named Roy Fielding’s dissertation. Amaze your friends and control your enemies with this information.

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

How are namespaces used in C#?

A

Namespaces let us organize our code and divide it into distinct sections. A class name declared in one namespace wouldn’t conflict with a class named the same thing in another namespace. We can have nested namespaces (such as Bangazon.Models).

The using directive allows us to alias namespaces that are built into the .NET ecosystem. For example, every time we wanted to use a List we COULD type out the full name with its namespace:

System.Collections.Generic.List listOfStuff = new System.Collections.Generic.List();

But that’s a mouth full! Instead, we can add a using directive:
using System.Collections.Generic

And that allows us to “alias” everything in that namespace (it means we don’t have to type out the full thing and can can just start with the word List).

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

What are Razor Views?

A

Razor views use markup syntax to build HTML pages in C#/.NET. Razor views are an example of server-generated HTML, which means the C#/.NET code running on the server decides how the web page should look and what should be displayed and then sends a finished product to the server. In what we used, Razor Views were the “V” in MVC apps. (Model, View, Controller).

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

What is git?

A

Git is a hugely popular version control system. We used the git CLI (command line interface), which means we accesses git from our terminals.

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

What is Github?

A

GitHub is an online hosting platform for git repositories. GitHub is often used for open-source development.

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

What is a Single Page Application (and why is it more efficient)?

A

A single page application (SPA) is an app that uses JavaScript to change out content on the web page. In a SPA, there is only one HTML file. You’ve been building SPAs this whole time without knowing it!

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

What is Version Control?

A

Version control is a system to track changes in your code (also called “versions” of your code). Git is by far the most common version control system and it’s the one we used.

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

What does strongly typed vs. loosely typed mean?

A

Strongly typed languages need to know what data types you’re working with (for example, when you declare a variable in C# you need to specify whether it’s a string or an integer). Loosely typed languages (like JavaScript) don’t need you to specify.

22
Q

What is an interface? And why do we use them?

A

A language construct that is similar to a class (in terms of syntax) but is fundamentally different. We use them to build loosely-coupled applications. An application whose components are not tightly related to each other.

23
Q

What is a Constructor?

A

A constructor is a method that is called when an instance of a class is created. This is often used as a way of creating test data to implement new features into programs without affecting real data.
EX:
public class Customer
{
public string Name;
Public Customer(string name)
{
this.Name = name;
}
}

24
Q

What is the difference between a reference type and a value type?

A

Variables of reference types store references to their data(objects), while variables of value types directly contain their data.
A value type holds a data value directly within its own memory space.
Value type: int I = 100;
Bool, Byte, Char, Decimal, Double, Enum, Int

Reference types are copies made by the system and act as a pointer to the real value
Reference type: string s = “Hello World”;
Strings, Arrays, Classes

25
Q

Is it bad practice to seed data by manually inputting an Id in C#?

A

It can be acceptable but isn’t generally recommended because of Data inconsistency, Scalability, Integrity and Relationships, and Maintenance. It’s ok as long as it doesn’t reflect real-world scenarios. Really you should try to use auto-incrementing Id’s whenever possible

26
Q

What are Object Initializers?

A

Object initializers initialze objects without the use of many constructor methods
var person = new Person
{
FirstName = “Spencer”,
LastName = “Lott”
};

27
Q

What are fields in C#?

A

It’s like a variable that we declare at the class level and we use that to store data about that class

28
Q

What is a readonly field and what is it’s purpose?

A

It is a modifier to make sure that it is only assigned once. I creates safety in your application.

29
Q

What is Method Overloading?

A

Having a method with the same name but with different signatures.

30
Q

What is an HTTP request? And what are some examples?

A

An HTTP request is an action to be performed on a resource identified by a given Request-URL. There are various methods, but each has it’s own purpose.
GET - retrieve and request data from a specified resource in a server
POST - send data to a server to create or update a resource. Usually user-generated data
PUT - same as POST, but it is idempotent meaning if you call the same PUT requests multiple times the results will always be the same
DELETE - removes the targeted resource
PATCH - similar to POST and PUT, but it’s purpose is to apply partial modifications to the resource. Non idempotent.
TRACE - N/A right now
CONNECT - establishes a tunnel to the server identified by a specific URL

31
Q

What are CI/CD pipelines?

A

It stands for continuous integration/ continuous deployment. The closest thing I have used to is data migrations. I have also used git to manage source code on team projects

32
Q

What is Open-Source?

A

It’s source code that anyone can inspect, modify, and enhance

33
Q

What is ASP.NET?

A

ASP.NET is a framework that allows us to create applications for the web. We build API’s and MVC applications in ASP.NET. The only thing we built in the server-side half of the course that DIDN’T use ASP.NET was our command line applications that ran in the terminal.

34
Q

What’s a Method?

A

A method is a function that’s defined inside an object. Methods are used to determine how an object behaves. In the following example of a JavaScript object, sayHello is a method.

const liamObject = {
age: 27,
height: “5’10”,
sayHello: function(){
console.log(“Hello, my name is Liam”.)
}
}

We can call our method like this:
liamObject.sayHello()
// Expected output: “Hello, my name is Liam.”

35
Q

What is ADO.NET?

A

ADO.NET is a database interface tool that uses raw SQL to query the database. ADO.NET has very little magic/ abstraction. You have to write a lot of code, but it’s extremely fast.

36
Q

What do you like about .NET?

A
  • Usable amongst many languages
  • Supports C#
  • Structured well
    *Loads if documentation and information on it
37
Q

What is the difference between .NET and the .NET Framework?

A

.NET Framework only runs on windows. Modern .NET works on Windows, Linux, and mac and is recommend for new development. Both are used by companies today.

38
Q

What is Exception Handling, and why is it important?

A

Different errors can occur whether that was due to the programmer or unanticipated events. When that happens C# will normally stop and generate an error message, i.e. throw and error. This is handled by using a try catch block. You handle errors to prevent the application from crashing.
Try contains the code to test
Catch contains the block of code to handle the errors.

–Throw will give you the error stack connected to the function for example and you can go through and debug getting even more context to why the error is thrown.

39
Q

What is a Static Class in C#?

A

It refers for example to a class, method , variable etc… that CANNOT BE INSTANTIATED. It makes that base information available to other parts of your code.

40
Q

What is a Dictionary in C#?

A

A dictionary is similar to an object. It is a collection of key/value pairs. However, since C# is strongly typed, we must be explicit about the type of the key and the type of the value

Dictionary< string, int > bowlingScores = new Dictionary< string, int >();bowlingScores.Add(“Marvin”,80);bowlingScores.Add(“Denise”,290);bowlingScores.Add(“Alef”,220);bowlingScores.Add(“Wilma”,200);

Note the <string, int> portion of the type. In this case string and int are referred to as “type parameters”. These type parameters tell C# we want a Dictionary whose keys are strings and whose values are integers.

41
Q

What is an ENUM in C#?

A

An enum is a special “class” that represents a group of constants
Ex.
Days = { Sun, Mon, Tue, Wed, Thu, Fri, Sat}
// Sun = 0, Mon == 1, Tue, == 2 … And so on.

42
Q

What is SQL?

A

SQL is a standard database management language for storing, manipulating, and retrieving data in databases.

43
Q

What is a Query?

A

It is a request for data or information from a database table or combination of tables. There are select queries and action queries.

44
Q

What is XML?

A

It’s a software and hardware tool for storing and transporting data. Really it’s just information wrapped in tags.
It’s different than HTML in that HTML displays data while XML carries data.

45
Q

What does LEFT JOIN do?

A

Left Join returns all rows from the left table, and the matching rows from the right table

46
Q

What are indexes in SQL?

A

Indexes are special lookup tables that need to be used by the database search engine to speed up data retrieval.

47
Q

What are Constraints in SQL?

A

Constraints are used to specify the rules concerning data in the table.
Some include NOT NULL, PK, FK, UNIQUE(ensures all values in a column are different), INDEX, DEFAULT

48
Q

What is the difference between an Array and and ArrayList in C#?

A

An Array holds one value type. Whereas an ArrayList can hold multiple value types like strings, doubles, ints, and Boolean values all in the same ArrayList

49
Q

What is WASM?

A

Web Assembly - used for compiling and executing code in a client side web browser

50
Q

What is DHCP

A

Domain Host Configuration Protocol- configure network devices to communicate on an IP network

51
Q

What is DNS?

A

Domain Name System - turns domain names into IP addresses, which browsers use to load internet pages

52
Q

What’s an IP Address?

A

An IP address is a unique address that identifies a device on the internet or a local network. IP stands for “Internet Protocol”