Programming Flashcards

1
Q

Define : Interface

A

Defines the things that something makes available to the outside world.

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

Members of an interface are implicitly

A

public and abstract, and are required to be so.

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

How class indicates that it implements an interface (code example)

A

public class AwesomeClass : InterfaceName { implementation of methods}

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

You can implement multiple interfaces at the same time

A

True

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

You can implement interfaces and declare a base class at the same time

A

True

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

How interface is defined (code example)

A

public interface InterfaceName { members }

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

A class that implements an interface does not have to provide implementation for all of the members of the class

A

False

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

A class that implements an interface is allowed to have other members that aren’t defined in the interface

A

True

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

A class can have more than one base class

A

False

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

Define : Polymorphism

A

You can create derived classes that implement the same method in different ways

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

How to implement polymorphism in the base class

A

mark the method as ‘virtual’

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

How to implement polymorphism in a derived class

A

mark it ‘override’ and provide alternative implementation

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

How to prevent creation of instance from base class

A

mark the class as ‘abstract’

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

How to force derived classes to implement methods that don’t exist in base class

A

In the base class create an empty method marked as abstract

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

New keyword attached to a method means?

A

A new method is being created unrelated to any methods in the base class. This is not great.

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

What are generics?

A

A way to create type-safe classes and structs without needing to cmmit to a specific data type at design time.

17
Q

Define a List (code example)

A

List listofStrings = new List();

18
Q

The core .Net classes that use generics:

A

List, Dictionary, IEnumerable

19
Q

Define Type-Safety

A

When you always know what type of object you are working with

20
Q

Using Collection Initializer syntax with a list (code example)

A

List ListOfInts = new List {1,2,3};

21
Q

Define : IEnumerable

A

Allows a collection to give others the ability to look at a list one item at a time.

22
Q

Define a Dictionary (code example)

A

Dictionary phonebook = new Dictionary();

23
Q

Define the problem generics address

A

Type-safety without creating many similar types

24
Q

Two methods to remove items from a list

A

RemoveAt and Clear

25
Q

Define a generic class (code example)

A

public class PracticeList { stuff }

26
Q

What variable structure are generic type names commonly?

A

Using a single capital letter, generally ‘T’ for singles, or if multiple, like ‘TKey & TValue’

27
Q

What is the default operator?

A

Used to get default value of a type, for example default(int)

28
Q

Default values for integer, float, bool, char, enum, strings & arrays, struct

A
integer & float : 0
bool : false
char : 0 / null control character
enum : 0
strings & arrays : null
struct : each element takes default value for its type
29
Q

Generic classes can only have one generic type parameter

A

false

30
Q

Generic type constraints limit what can be used for the generic type

A

true

31
Q

Constraints let you use the methods of the thing you are constraining to

A

True