General Coding Flashcards

1
Q

The STACK is…..

A

The stack is the block of memory for storing local variables

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

The HEAP is…

A

The heap is the block of memory in which OBJECTS reside

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

What does REST stand for?

A

Representational State Transfer

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

How do you run a Psake command from the powershell?

A

.\packages\psake.4.3.2\tools\psake.ps1 [Command] eg .\packages\psake.4.3.2\tools\psake.p21 RebuildDatabase

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

What does IIS stand for?

A

Internet Information Services

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

What is the S in SOLID?

A

Single Responsibility

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

What is the O in SOLID?

A

Open / Close Principle

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

What is UPCASTING?

A

Creating a BASE class reference from a SUBCLASS reference

eg

Cow myCow = new Cow();

Animal animal = cow; //Upcast

//**animal can only use the methods/properties available to Animal but would take anything across from myCow**//

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

What is DOWNCASTING?

A

Creating a SUBCLASS reference from a BASE class reference

eg

Animal myAnimal = new Animal();

Cow myCow = (Cow) myAnimal;

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

What does the ‘as’ operator do?

A

It performs a DOWNCAST but will return null if the downcast fails

eg

Animal myAnimal = new Animal();

Cow myCow = myAnimal as Cow;

this can be followed with an !=null check to confirm the type

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

What does the ‘is’ operator do?

A

It checks whether an object is of a certain type

eg

if (myAnimal is Cow)

{……}

/**Cow would be a type eg Cow myCow = new Cow(); **/

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

Is GOLD PLATING a GOOD thing or a BAD thing? Why?

A

It’s viewed as a BAD thing as it represents work / development that was not requested and is therefore wasteful

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

What is the difference between CONST and READ ONLY?

A
  1. CONST must be declared and initialised on compile, READ ONLY can be initialised during the run time, but once the value has been set it can’t be changed

So within an object, you can have different values set for each instance of the object, but any CONST values would be the same across them all.

NB: Both are static

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

What are the differences between Abstracation and Encapsulation?

A

Abstraction:

  1. Abstraction is a concept of hiding mechanism.
  2. Only showing those parts which are necessary.
  3. It is a thought process used in design level.

Encapsulation:

  1. Encapsulation is the implementation of that concept.
  2. Hiding complexity.
  3. Here it is the actual process of hiding the ‘mechanics’ of the class.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How do you convert the following the following method so that the CheckUserName method is run to asynchronously?

private void Login(name)

{

if (CheckUserName(name))

{

MessageBox.Show(“Name Ok”);

};

}

A

private async Task LoginAsync(name)

{

var result = await Task.Run(() => CheckUserName(name));

if (result)

{

MessageBox.Show(“Name Ok”);

}

}

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

Convert the following task to ASYNC:

private bool IsValidUser(name)

{

if(IsInTheDatabase(name))

{

return true;

}

return false;

}

A

private async Task IsValidUser(name)

{

var check = await IsInTheDatabase(name);

return check.result;

}

17
Q

Convert the following to async:

public ActionResult Index()

{

using (var db = new AriaDBContext())

{

var query = db.GetAllUsers();

return View(“Index”, query);

}

}

A

public async Task Index()

{

using (var db = new AriaDBContext())

{

var query = await db.GetAllUsers();

return View(“Index”, query.result);

}

}

18
Q

In Visual Studio, how can you quickly see the list of parameters expected within a method call?

A

Ctrl + Space

19
Q

What is Abstraction?

A

It’s an OOP principle where we show only necessary things to the consumer.

20
Q

If you have a static class, when do you need to instantiate it and how many instances can you instantiate?

A

This is a trick question, you don’t need to instantiate a static class, it’s always available. However because of this you can only ever have one ‘instance’ of it available. The contents of which remains static across the application.

However, it’s worth noting that although the variables and methods within the static object don’t change, it can still return different values (including different objects and instances of objects) from it’s methods

21
Q

Lazy Loading

A

Lazy Loading :- This is a creational design pattern where we load objects only when we need it. The opposite of Lazy loading is eager loading.

22
Q
A