SpringCM On-Site Flashcards

1
Q

What is a namespace

A

A namespace is designed for providing a way to keep one set of names separate from another. The class names declared in one namespace does not conflict with the same class names declared in another. Similar to a package in Java

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

What is using keyword

A

It is similar to an import statement. It means that you are bringing in a namespace to another location. Or namespace

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

Name 3 ways to pass parameters to a method

A

Value parameters : This method copies the actual value of an argument into the formal parameter of the function. In this case, changes made to the parameter inside the function have no effect on the argument.

Reference parameters : This method copies the reference to the memory location of an argument into the formal parameter. This means that changes made to the parameter affect the argument.

Out parameters : This method helps in returning more than one value.

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

What is the ultimate base class for everything in C#

A

The Object class.

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

Boxing vs. Unboxing

A

Boxing: When a value type is converted to an object. Think int to Integer.
Unboxing: When an object is converted to a value type

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

what are dynamic type variables?

A

You can assign these to variables and their types are checked at RUNTIME

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

How to extend a class in C#

A

MyClassSub : MySuperClass

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

What is a sealed class?

A

A class that cannot be inherited

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

Difference between value type and reference type

A

Value type directly contain data (i.e int, char, float)

Reference types do not contain actual data of variable but a reference to the the variable. Points to memory location

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

pointer types in c#?

A

store the memory address of another type. behave like pointers in c#. these are

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

How do you cast in c#

A

you can use the as keyword. Obj as StringBuilder

(Stringbuilder) Obj <= java equivalent

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

what are Nullable types?

A

These are types similar to normal value types but also allow a null. Nullable would allow for a null integer.

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

How can you enforce garbage collection in .NET

A

System.GC.Collect();

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

Stack vs Heap

A

stack: stores value types
heap: stores reference types

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

How would you improve your solution?

A

Maybe use a lambda or two? It would make it easier to code, but i believe I wrote my solution to be as readable as possible
I think using an enumuration for the test text files would be better. However, I believe C# doesn’t support String enums.
I think for larger text files, it would make sense to divide the content into chunks. This could split the work into separate threads. However, it seemed as if it finally took a millisecond around a couple thousand words.
Could I have used LINQ to possibly make a query? LINQ is a bit more expressive. It might have been easier to do this instead

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