C# study - Sheet1 Flashcards

1
Q

In .NET, you don’t immediately create operating system-specific native code. Instead, you compile into Common Intermediate Language code.

A

T

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

What is the term for the .Net method of freeing up unused memory?

A

Garbage Collection

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

C# is a typesafe language.

A

T

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

Console applications are simple command-line applications

A

T

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

What type of language is C#

A

block-structured language

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

What are comments for?

A

Adding descriptive text to code.

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

Name four integer types.

A

byte, short, int, long

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

A string is a sequence of numbers

A

F

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

Give an example of a camelcase variable name.

A

firstName

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

What are the allowed value of Boolean?

A

True or False

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

What are the 3 categories that operators can be divided into

A

Unary, Binary, Ternary

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

Variables are chunks of data that have a name and a type.

A

T

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

What are the three branching techniques available in C#?

A

Ternary, If, Switch

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

In a switch statement, it is legal to execute more than one case.

A

T

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

Looping refers to the repeated execution of statements.

A

T

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

How do implicit and explicit conversions differ?

A

Implicit: conversion is possible in all circumstances, and the compiler can do it. Explicit: conversion is possible only in certain circumstances.

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

Structs can’t have different data types in them

A

F

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

What is the term for variable in a struct?

A

data members

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

What is a struct?

A

data structures that are composed of several pieces of data, possibly of different types.

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

How many base types are in an array?

A

1

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

How do you declare an array?

A

[] ;

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

What do foreach loops enable?

A

Enables you to address each element in an array.

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

A jagged array is an array of arrays of different lengths.

A

T

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

When a function returns a value, you have to specify the type in the function declaration, and use the return keyword at the end of the function’s execution.

A

T

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

Passing a parameter by reference means the referenced variable will be used each time a function is run rather than using a constant number.

A

T

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

Global variables can have a scope of more than one function?

A

T

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

A delegate is a type that enables you to store references to functions.

A

T

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

What is the main advantage of using Release builds?

A

Release builds run faster.

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

When in debug mode in Visual Studio the step into command will execute and move to the next statement to be executed.

A

T

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

Error handling is the term for all techniques involving finding and correcting errors.

A

T

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

Nondefault constructors are constructors that include starting parameters

A

T

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

Default constructors are parameter-less methods (that don’t return anything).

A

T

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

Who are static members shared with?

A

They are shared between instances of a class.

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

Interfaces can exiswt on their own.

A

F

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

What is an interface?

A

A collection of private instance methods and properties that are grouped together.

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

What does the term inheritance mean in OOP?

A

It wil have all the members of the class from which it inherits.

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

In C#, all classes derive from the base class Parent at the root of the class.

A

T

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

What does polymorphism allow?

A

All objects instantiated from a derived class can be treated as if they were instances of a parent class.

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

What is containment?

A

One class contains another.

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

What is the base class in C#?

A

System

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

Abstract classes can posses both abstract members and non-abstract members.

A

T

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

Abstract classes can contain members that can be inherited by a derived class, while interfaces cannot.

A

T

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

When you assign an object to a variable, you are actually assigning that variable with a pointer to the object to which it refers.

A

T

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

A full copy is referred to as a deep copy.

A

T

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

Within a class definition, all members have the same accessibility levels.

A

F

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

Public members are accessible from any code

A

T

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

Protected Members are accessible only from code that is part of either the class or a derived class.

A

T

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

A Field is like a variable.

A

T

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

A method is like a function.

A

T

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

Fields, methods, and properties can also be declared using the keyword global, which means they are static members owned by the class.

A

F

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

Where can you access private members from?

A

Code that is part of the class.

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

Which keyword’s members are accessible only from code within the assembly (project) where they are defined

A

Internal

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

What are the four class definition modifiers for accessibility?

A

public, private, internal, protected

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

If override is used, then sealed can also be used to specify that no further modifications can be made to this method in derived classes

A

T

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

Accessors are defined using get and set keywords respectively, and can be used to control the access level of the property.

A

T

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

What does the override method do?

A

overrides a base class method.

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

Properties contain a type name, a property name, and one or both what kind of blocks?

A

Get / Set

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

You must use an accessor to make a property useful.

A

T

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

Properties use the same keywords as fields and methods.

A

T

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

What does the keyword “value” refer to?

A

Equates to a value of the same type as the property.

61
Q

Refactoring is modifying your code using a tool, rather than by hand.

A

T

62
Q

The only limitation of automatic properties is that they must include both a Get and Set acessor.

A

T

63
Q

When you inherit a non-abstract member from a base class, you also inherit an implementation.

A

T

64
Q

Why properties are the preferred way to access the state of an object

A

They shield external code from the implementation of data storage within the object.

65
Q

With an automatic property, you declare what?

A

A property with a simplified sytax.

66
Q

When a base implementation is hidden, how can you still access it?

A

Use the base keyword.

67
Q

You can define types such as classes in namespaces, and you can also define them inside other classes.

A

T

68
Q

The most useful function of the base keyword is the capability to pass a reference to the current object instance to a method

A

F

69
Q

Like base, this refers to an object instance, although it is a future object instance.

A

F

70
Q

What does the “this” keyword referto?

A

an object instance

71
Q

What is the keyword this used for in C#?

A

the capability to pass a reference to the current object instance to a method.

72
Q

Interface members are defined like functions.

A

F - class members

73
Q

Interfaces can contain code bodies.

A

F - they can’t

74
Q

Why would you want to use the “new” keyword in defining interface members?

A

If you want to hide members inherited from base interfaces.

75
Q

A class that implements an interface must contain implementations for all members of that interface,

A

T

76
Q

Interface values specify how the property data should be stored.

A

F

77
Q

It is possible to implement interface members using the keyword virtual or abstract but no static or const.

A

T

78
Q

Interface members cannot be implemented explicitly by a class.

A

F

79
Q

It is possible to add a get block to a property in a class in which the interface defining that property only contains a set block, and vice versa.

A

T

80
Q

What is the code that allows fields to expand and contract?

A

region and #endregion

81
Q

What is one technique to avoid confusing and cluttered code as described in chapter 10?

A

Code outlining.

82
Q

Partial methods are defined in one partial class definition without a method body, and implemented in another partial class definition.

A

T

83
Q

Methods can be split using partial keyword?

A

T

84
Q

What is a partial class definition used for?

A

put the fields, properties, and constructor in one file, and the method in another.

85
Q

What is the keyword that allows methods to be split between multiple files.

A

partial

86
Q

Partial methods can be static.

A

T

87
Q

What happens when you complie code that contains a partial method definition without an implementaiton?

A

thecompler removes the method entirely.

88
Q

Properties and methods can be defined as abstract or virtual in base classes to define inheritance

A

T

89
Q

A class that implements an interface must implement all of the members defi ned by that interface as private

A

F

90
Q

Partial methods have certain restrictions, including no return value or out parameters.

A

T

91
Q

Properties and methods can be defined as ______ or ______ in base classes to define inheritance.

A

abstract or virtual.

92
Q

Which member has an accessibility, return type, name, and parameters?

A

Field

93
Q

Unlike arrays, collections can control access to the objects they contain, search and sort, and more.

A

T

94
Q

What do collections enable you to maintain?

A

groups of objects

95
Q

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

A

T

96
Q

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

A

T

97
Q

Arrays in C# are implemented as instances of the System.Array class and are just one type of what are known as collection classes.

A

T

98
Q

The System.Array class supports some of the more advanced features of IList, and it represents a list of items by using a fixed size.

A

T

99
Q

Collection classes in general are used for maintaining lists of objects.

A

T

100
Q

Custom collection classes can be strongly typed.

A

T

101
Q

Much of the functionality for collection classes comes through implementing interfaces from the System.Interfaces namespace.

A

T

102
Q

System.Array is just one example of a collection class in C#.

A

T

103
Q

What does ienumerable do?

A

Provides the capability to loop through items in a collection.

104
Q

What does icollection do?

A

Provides the capability to obtain the number of items in a collection and copy them into a simple array type.

105
Q

Collections contain a constructor that will double the capacity automatically if the number of items in the collection ever exceeds the initial value.

A

T

106
Q

With arrays of reference types, simply initializing the array with a size initializes the items it contains.

A

F

107
Q

You can derive a collection from a class, such as System.Collections.CollectionsBase.

A

T

108
Q

What is the recommended way to derive a collection you create from a class as described in our text?

A

Using the Systm.Collections.CollectionBase

109
Q

Two methods provided by the CollectionBase interface are Clear() and RemoveAt().

A

T

110
Q

What is a special kind of property that you can add to a class to provide array-like access

A

indexer

111
Q

What does an indexer property do?

A

Provides array-like access

112
Q

What does CollectionBase interface do in C#?

A

Provides 2 protected properties that enable access to the stored objects themselves.

113
Q

The this keyword is used along with parameters in round brackets

A

T

114
Q

As with indexed collections, there is a base class you can use to simplify implementation of the IDictionary interface: DictionaryBase.

A

T

115
Q

How does IDictionary differ from IList?

A

RemoveAt() is not included.

116
Q

The Remove member Takes a key parameter and an object reference.

A

F

117
Q

One difference between collections based on DictionaryBase and collections based on CollectionBase is that foreach works differently.

A

T

118
Q

The IEnumberable interface allows the use of foreach loops.

A

T

119
Q

What does the add member do?

A

It takes two parameters and stores them together.

120
Q

The IEnumerable interface enables you to use what kind of loop?

A

foreach

121
Q

To iterate over a class, use a method called what?

A

GetEnumerator with IEnumerator as the return type.

122
Q

To iterate over a class member, such as a method, use what?

A

IEnumerable

123
Q

A good definition of an iterator is a block of code that supplies all the values to be used in a foreach block in sequence.

A

T

124
Q

What is a good definition of an iterator?

A

A block of code that supplies all the values to be used in a foreach block in sequence.

125
Q

Within an iterator block, you select the values to be used in the foreach loop by using which keyword?

A

yeild

126
Q

It is impossible to interrupt the return of information to a foreach loop.

A

F

127
Q

Value comparisons determine what an object is or what it inherits from.

A

F

128
Q

What are two types of comparisons between objects?

A

Type and Value

129
Q

What is boxing (in terms of C#, not the sport)?

A

The act of converting a value type into the System.Object type or to an interface type that is implemented by the value type.

130
Q

If is a class type, then the result is true if is of that type, if it inherits from that type, or if it can be boxed into that type.

A

T

131
Q

If is a value type, then the result is true if is of that type or it is a type that can be unboxed into that type.

A

T

132
Q

The “is” operator enables you to check whether an object either is or CAN BE CONVERTED into a given type.

A

T

133
Q

What is the syntax for the “is” operator?

A

is

134
Q

What does the is operator enable?

A

You to check whether an object is or can be converted into a given type.

135
Q

Class overloading enables you to use standard operators, such as +, >, and so on with classes that you design.

A

F

136
Q

What does operator overloading enable you to do?

A

You to use standard o[erators with classes that you design.

137
Q

Why is operator overloading useful?

A

you can perform whatever processing you want in the implementation of the operator overload.

138
Q

Operator overloads look much like standard static method declarations.

A

T

139
Q

If you overload the true and false operators, then you can use classes in Boolean expressions, such as if(op1){}.

A

T

140
Q

Assignment operator cannot be overloaded

A

T

141
Q

What parameter does equals() use

A

object

142
Q

Where is Icomparable implemented

A

In the class of the object to be compared.

143
Q

What does the IComparer interface allow?

A

Allows comparisons between that object and another object.

144
Q

When using Comparer, the types don’t have to be comparable.

A

F

145
Q

Strings are processed in case-sensitive way.

A

T

146
Q

What does the “as” operator convert?

A

Converts a type into a specified reference type.

147
Q

You can use the GetType() method to obtain the type of an object, or the typeof() operator to get the type of a class.

A

T

148
Q

To iterate over a class, implement a method called GetEnumerator() with a return type of IEnumerable.

A

T

149
Q

What are collections

A

Classes that can contain instances of other classes.