T Interv.NEiew Flashcards

1
Q

What is composition?

A

The ability to build functions by using other functions is called composition

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

what is scaffolding?

A

Code that is used to assist with development and debugging. Unit test code is an example of scaffolding.

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

What is the difference between a block and a body?

A

A block is group of consecutive statements with the same indentation.

A body is a kind of block that is found after a method’s header.

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

What is an example of definite iteration?

A

a for loop

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

What is an example of indefinite iteration?

A

a while loop

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

What are collection classes used for?

A

maintaining lists of objects

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

What is IList used for?

A

IList Provides a list of items for a collection along with the capabilities for accessing these items, and some other basic capabilities related to lists of items

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

What is IDictionary used for?

A

IDictionary — Similar to IList, but provides a list of items accessible via a key value, rather than an index

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

Can an interface have a body?

A

No

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

An abstract class allows you to create functionality that subclasses _______

A

inherit (or override??)

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

Can you apply access modifiers to abstract classes or interfaces, which one?

A

Only abstract classes

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

Do you use abstract classes or interfaces to provide multiple inheritance in C#?

A

Interfaces only

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

What access modifier must interface members be implicitly implemented with?

A

public

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

What is the syntax for explicit implementation?

A

.

IFile.ReadFile()

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

Describe an interface

A

An interface is an empty shell. Only signatures, no bodies. An interface can’t do anything. It’s just a pattern.

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

Can you define behavior in an interface?

A

No. Interfaces can only have signatures.

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

Which constructor would be called first? A base class, or a sub class?

A

sub class

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

What is the essential difference between interfaces and abstract classes?

A

Where you want to define behavior

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

Is an abstract class an example of a “is-a” relationship, or a “has-a” relationship?

A

is-a

a Tank is a Vehicle

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

Are abstract classes or interfaces “implemented”, which one?

A

interfaces

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

Are interfaces or abstract methods more expensive to use?

A

abstract classes

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

If the proposed base class doesn’t provide default implementations for your methods, is this a reason to choose inheritance or an interface?

A

interface

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

If it makes sense to call a method even when no object has been constructed yet, how should that method be defined?

A

static

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

Can you override a static method?

A

no

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

Does a static method produce a state?

A

no

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

If there is some code that can easily be shared by all the instance methods, what should you do with that code?

A

Extract that code into a static method

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

Can a static method be garbage collected?

A

No

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

Is using static methods is always thread safe?

A

No

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

If you have something consuming your classes, and you want to ensure that all of the classes implement the same methods and properties, but not necessarily the same functionality, what would you use?

A

Interfaces

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

If you have common functionality you want available in all child classes, where each child class can extend or override the parent class code, what should you use?

A

you should use inheritance (Abstract classes)

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

A METHOD without a body is known as?

A

An abstract method

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

Can you create an object from an abstract class?

A

No

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

What is abstraction?

A

Data abstraction is the process of hiding certain details and showing only essential information to the user

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

A constructor name must match _________, and it cannot have a _________

A

The class name, a return type

35
Q

Describe Process vs Thread?

A

Process is an independent execution unit with its own state and memory; Architectural construct.

Threads exist inside of a Process and share state and memory; coding construct

36
Q

What is overloading?

A

Adding to the functionality of a method, while keeping the same name. It’s a compile time event.

int add(int a, int b) return a+b;   
int add(int a, int b, int c) return a+b+c;

(note, both of these are usable, the second one doesn’t overwrite the first one. So overloading is a way of adding to the capabilities of a method, while overriding is re-writing methods that already exist)

37
Q

What is the default access modifier for a namespace?

A

internal

38
Q

What is the difference between IEnumerable and ICollection?

A

When we define a property as IEnumerable, we can only iterate through each item. But when we define a property as ICollection, we can add, edit, update and delete an item.

39
Q

What is overriding?

A

You override a virtual method in a sub class. Overriding concerns defining a different implementation of the same method in inherited classes. It is a runtime event

40
Q

what is hiding?

A
public class Base_Parent {  
    public void show() Console.WriteLine("This is my parent class.");
}
public class Derived _Parent : Base_Parent {
    public new void show() Console.WriteLine("This is my child class.");
}
41
Q

Are abstract classes or interfaces “inherited”?

A

abstract classes

42
Q

An event is nothing but a?

A

encapsulated delegate

43
Q

How would you declare an event for the following delegate?

public delegate void ClickHandler();

A

public event ClickHandler OnClick;

44
Q

Which of the following is the built-in delegate function for handling events in .NET?

A

public delegate void EventHandler(object sender, EventArgs e);

45
Q

online c# tests

A

https://www.tutorialsteacher.com/question-answer/csharp/delegates-events/2

46
Q

Which can only be initialized at the class-level, const or readonly?

A

readonly

47
Q

What are fields?

A

variables inside a class

48
Q

Which is a compile time constant, const or readonly?

A

const

49
Q

Which can be changed, const or readonly?

A

readonly

50
Q

What kind of search starts at a given node and explores as far as possible along each branch before back tracking?

A

Depth-first search

51
Q

What kind of search starts at a given node and explores all neighboring nodes before moving deeper?

A

Breadth-first search

52
Q

What does the public access modifier do?

A

The type or member can be accessed by any other code in the same assembly or another assembly that references it

53
Q

In BFS, we need to maintain a separate data structure for tracking the nodes yet to be visited.

A

In DFS doesn’t need any additional data structure to store the nodes. The recursive implementation of DFS uses the call stack

54
Q

How does garbage collection work in C#?

A

Automatic by default, though you can do it manually using pointers

55
Q

What triggers garbage collection in C#?

A

An allocation is made any time you declare an object with a “new” keyword.

When there is not enough memory to allocate an object, the garbage collector must collect and dispose of garbage memory.

56
Q

Why would you ever use SQL over LINQ?

A

SQL is still faster. And you still sometimes need SQL for hand-tweaked queries - especially with optimization or locking hints. Most providers don’t support the use of LINQ for predicated updates, and of course you still need SQL for triggers.

57
Q

What do LINQ to SQL queries compile into?

A

SQL queries

58
Q

Why use LINQ over SQL?

A
Shorter, more readable code
No magic strings
Intellisense
Compile check when database changes
Unit of work pattern (context)
Lazy loading
59
Q

What is an enum?

A

An enum is a special “class” that represents a group of constants

60
Q

What are assemblies in C#?

A

compiled .exe or .dll files

61
Q

What does the private access modifier do?

A

The type or member can be accessed only by code in the same class or struct.

62
Q

What is encapsulation?

A

The meaning of Encapsulation, is to make sure that “sensitive” data is hidden from users. To achieve this, you must:

Declare fields/variables as private

Provide public get and set methods, through properties, to access and update the value of a private field

63
Q

When to use DFS and BFS?

If we know the solution lies somewhere deep in a tree or far from the source vertex in the graph, use DFS.

A

If we know the solution is not that far from the source vertex, use BFS.

If our tree is broad, use DFS as BFS will take too much memory. Similarly, if our tree is very deep, choose BFS over DFS.

64
Q

What does the protected access modifier do?

A

The type or member can be accessed only by code in the same class, or in a class that is derived from that class.

65
Q

Entity Framework questions

A

x

66
Q

MVC vs MVVM

A

x

67
Q

How do you prevent deadlocks when two threads need the same n resources?

A

A deadlock occurs when each thread (minimum of two) tries to acquire a lock on a resource already locked by another. Thread 1 locked on Resources 1 tries to acquire a lock on Resource 2. At the same time, Thread 2 has a lock on Resource 2 and it tries to acquire a lock on Resource 1. Two threads never give up their locks, hence the deadlock occurs.

The simplest way to avoid deadlock is to use a timeout value. The Monitor class (system.Threading.Monitor) can set a timeout during acquiring a lock.

68
Q

What are your options if a resource must be locked in one section and released in another?

A

x

69
Q

What does ThreadStatic mean?

A

The [ThreadStatic] creates isolated versions of the same variable in each thread. Fields marked with [ThreadStatic] are created on Thread Local Storage so every thread has it own copy of the field i.e the scope of the fields are local to the thread.

70
Q

What is reflection? (Why would you use it and also why wouldn’t you use it?)

A

x

71
Q

Have you heard of SOLID? (can you show examples in your code, does the code you submitted violate any of the SOLID principles?)

A

x

72
Q

What are the important qualities of a Unit Test?

A

x

73
Q

How would you mock or stub a sealed class that does not implement any interfaces? A static class?

A

x

74
Q

What does an API controller do?

A

x

75
Q

Explain C#’s reference and value types, and explain the differences.

A

x

76
Q

Explain what @Html. does and what it is.

A

x

77
Q

MVC Explain all of the steps that go into a user getting to a certain page. Try to list the events that occur and what order they happen in.

A

https://docs.microsoft.com/en-us/previous-versions/aspnet/ms178472(v=vs.100)

78
Q

viewstate/session state, what are the different http methods and what do we use them for, difference between full postback and Ajax requests etc

A

x

79
Q

What does the internal access modifier do?

A

The type or member can be accessed by any code in the same assembly, but not from another assembly.

80
Q

What is a value type?

A

Usually a simpler type of data, where the data and the pointer is kept on the stack

int
float
bool
char

81
Q

What is a reference type?

A

Usually more complex types of data, where the data is kept on the heap.

class
delegate
string
82
Q

What is a delegate?

A

A delegate in .NET is a way of passing behavior as a parameter. Similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object

Often used in async methods

83
Q

What is a namespace?

A

A group of classes, structures, interfaces, enumerations, and delegates—organized in a logical hierarchy