C# Lists / Collections / Classes / Objects Flashcards

1
Q

What is a list?

A

A list is similar to an array but provides additional functionality, such as dynamic resizing.

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

What is a collection?

A

The .NET Framework class library provides several classes, called collections, used to store groups of ralated objects. These classes provide efficient methods that organize, store and retrieve your data without requiring knowledge of how the data is being stored.

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

What is the generic collection class List?

A

The generic collection class List (from namespace System.Collections.Generic) does not need to be reallocated to change its size. List is called a generic class because it can be used with any type of object. T is a placeholder for the type of the objects stored in the list.

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

What are some common methods and properties of class List?

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

What does the count property do?

A

The count property returns the number of elements currently in the list

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

What does the capacity property do?

A

The capacity property indicates how many items the list can hold without having to grow

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

What are the capacity and count properties values when the list is initially created?

A

Both are initially 0, though the capacity is implementation dependent

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

How would you add items to the collection?

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

How does the elasticity of the capacity of a collection work?

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

What does the Add method do?

A

Appends its argument to the end of the list.

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

What does the insert method do?

A

inserts a new element at the specific position.

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

How would you index a list collection?

A

Lists can be indexed like arrays by placing the index in square brackets after the List variable’s name.

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

What does the remove method do?

A

the remove method is used to remove the first instance of an element with a specific value. If mp such element is in the list, remove does nothing.

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

What does the remove at method do?

A

It removes the element at the specified index; the indices of all elements above that index decrease by 1.

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

What does the contains method do?

A

The contains method returns true if the element is found in the list, and false otherwise.

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

What is a way to increase performance if you know there is wasted room in your list you will never use?

A
17
Q

What are collection initializers?

A
18
Q

How would you define a class?

A
19
Q

What is composition?

A

Some complicated types are composed of other types, an automobile class might be composed of wheels, engine, transmission etc. An automobile object would have four instances of the wheel class, and one instance each of the engine and transmission class.

20
Q

How is a constructor build and instantiated?

A
21
Q

What is the second way the “this” keyword can be used?

A
22
Q
A