C# study - Sheet1 Flashcards

(149 cards)

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
Passing a parameter by reference means the referenced variable will be used each time a function is run rather than using a constant number.
T
26
Global variables can have a scope of more than one function?
T
27
A delegate is a type that enables you to store references to functions.
T
28
What is the main advantage of using Release builds?
Release builds run faster.
29
When in debug mode in Visual Studio the step into command will execute and move to the next statement to be executed.
T
30
Error handling is the term for all techniques involving finding and correcting errors.
T
31
Nondefault constructors are constructors that include starting parameters
T
32
Default constructors are parameter-less methods (that don't return anything).
T
33
Who are static members shared with?
They are shared between instances of a class.
34
Interfaces can exiswt on their own.
F
35
What is an interface?
A collection of private instance methods and properties that are grouped together.
36
What does the term inheritance mean in OOP?
It wil have all the members of the class from which it inherits.
37
In C#, all classes derive from the base class Parent at the root of the class.
T
38
What does polymorphism allow?
All objects instantiated from a derived class can be treated as if they were instances of a parent class.
39
What is containment?
One class contains another.
40
What is the base class in C#?
System
41
Abstract classes can posses both abstract members and non-abstract members.
T
42
Abstract classes can contain members that can be inherited by a derived class, while interfaces cannot.
T
43
When you assign an object to a variable, you are actually assigning that variable with a pointer to the object to which it refers.
T
44
A full copy is referred to as a deep copy.
T
45
Within a class definition, all members have the same accessibility levels.
F
46
Public members are accessible from any code
T
47
Protected Members are accessible only from code that is part of either the class or a derived class.
T
48
A Field is like a variable.
T
49
A method is like a function.
T
50
Fields, methods, and properties can also be declared using the keyword global, which means they are static members owned by the class.
F
51
Where can you access private members from?
Code that is part of the class.
52
Which keyword's members are accessible only from code within the assembly (project) where they are defined
Internal
53
What are the four class definition modifiers for accessibility?
public, private, internal, protected
54
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
T
55
Accessors are defined using get and set keywords respectively, and can be used to control the access level of the property.
T
56
What does the override method do?
overrides a base class method.
57
Properties contain a type name, a property name, and one or both what kind of blocks?
Get / Set
58
You must use an accessor to make a property useful.
T
59
Properties use the same keywords as fields and methods.
T
60
What does the keyword "value" refer to?
Equates to a value of the same type as the property.
61
Refactoring is modifying your code using a tool, rather than by hand.
T
62
The only limitation of automatic properties is that they must include both a Get and Set acessor.
T
63
When you inherit a non-abstract member from a base class, you also inherit an implementation.
T
64
Why properties are the preferred way to access the state of an object
They shield external code from the implementation of data storage within the object.
65
With an automatic property, you declare what?
A property with a simplified sytax.
66
When a base implementation is hidden, how can you still access it?
Use the base keyword.
67
You can define types such as classes in namespaces, and you can also define them inside other classes.
T
68
The most useful function of the base keyword is the capability to pass a reference to the current object instance to a method
F
69
Like base, this refers to an object instance, although it is a future object instance.
F
70
What does the "this" keyword referto?
an object instance
71
What is the keyword this used for in C#?
the capability to pass a reference to the current object instance to a method.
72
Interface members are defined like functions.
F - class members
73
Interfaces can contain code bodies.
F - they can't
74
Why would you want to use the "new" keyword in defining interface members?
If you want to hide members inherited from base interfaces.
75
A class that implements an interface must contain implementations for all members of that interface,
T
76
Interface values specify how the property data should be stored.
F
77
It is possible to implement interface members using the keyword virtual or abstract but no static or const.
T
78
Interface members cannot be implemented explicitly by a class.
F
79
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.
T
80
What is the code that allows fields to expand and contract?
#region and #endregion
81
What is one technique to avoid confusing and cluttered code as described in chapter 10?
Code outlining.
82
Partial methods are defined in one partial class definition without a method body, and implemented in another partial class definition.
T
83
Methods can be split using partial keyword?
T
84
What is a partial class definition used for?
put the fields, properties, and constructor in one file, and the method in another.
85
What is the keyword that allows methods to be split between multiple files.
partial
86
Partial methods can be static.
T
87
What happens when you complie code that contains a partial method definition without an implementaiton?
thecompler removes the method entirely.
88
Properties and methods can be defined as abstract or virtual in base classes to define inheritance
T
89
A class that implements an interface must implement all of the members defi ned by that interface as private
F
90
Partial methods have certain restrictions, including no return value or out parameters.
T
91
Properties and methods can be defined as ______ or ______ in base classes to define inheritance.
abstract or virtual.
92
Which member has an accessibility, return type, name, and parameters?
Field
93
Unlike arrays, collections can control access to the objects they contain, search and sort, and more.
T
94
What do collections enable you to maintain?
groups of objects
95
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
T
96
IDictionary — Similar to IList, but provides a list of items accessible via a key value, rather than an index
T
97
Arrays in C# are implemented as instances of the System.Array class and are just one type of what are known as collection classes.
T
98
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.
T
99
Collection classes in general are used for maintaining lists of objects.
T
100
Custom collection classes can be strongly typed.
T
101
Much of the functionality for collection classes comes through implementing interfaces from the System.Interfaces namespace.
T
102
System.Array is just one example of a collection class in C#.
T
103
What does ienumerable do?
Provides the capability to loop through items in a collection.
104
What does icollection do?
Provides the capability to obtain the number of items in a collection and copy them into a simple array type.
105
Collections contain a constructor that will double the capacity automatically if the number of items in the collection ever exceeds the initial value.
T
106
With arrays of reference types, simply initializing the array with a size initializes the items it contains.
F
107
You can derive a collection from a class, such as System.Collections.CollectionsBase.
T
108
What is the recommended way to derive a collection you create from a class as described in our text?
Using the Systm.Collections.CollectionBase
109
Two methods provided by the CollectionBase interface are Clear() and RemoveAt().
T
110
What is a special kind of property that you can add to a class to provide array-like access
indexer
111
What does an indexer property do?
Provides array-like access
112
What does CollectionBase interface do in C#?
Provides 2 protected properties that enable access to the stored objects themselves.
113
The this keyword is used along with parameters in round brackets
T
114
As with indexed collections, there is a base class you can use to simplify implementation of the IDictionary interface: DictionaryBase.
T
115
How does IDictionary differ from IList?
RemoveAt() is not included.
116
The Remove member Takes a key parameter and an object reference.
F
117
One difference between collections based on DictionaryBase and collections based on CollectionBase is that foreach works differently.
T
118
The IEnumberable interface allows the use of foreach loops.
T
119
What does the add member do?
It takes two parameters and stores them together.
120
The IEnumerable interface enables you to use what kind of loop?
foreach
121
To iterate over a class, use a method called what?
GetEnumerator with IEnumerator as the return type.
122
To iterate over a class member, such as a method, use what?
IEnumerable
123
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.
T
124
What is a good definition of an iterator?
A block of code that supplies all the values to be used in a foreach block in sequence.
125
Within an iterator block, you select the values to be used in the foreach loop by using which keyword?
yeild
126
It is impossible to interrupt the return of information to a foreach loop.
F
127
Value comparisons determine what an object is or what it inherits from.
F
128
What are two types of comparisons between objects?
Type and Value
129
What is boxing (in terms of C#, not the sport)?
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
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.
T
131
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.
T
132
The "is" operator enables you to check whether an object either is or CAN BE CONVERTED into a given type.
T
133
What is the syntax for the "is" operator?
is
134
What does the is operator enable?
You to check whether an object is or can be converted into a given type.
135
Class overloading enables you to use standard operators, such as +, >, and so on with classes that you design.
F
136
What does operator overloading enable you to do?
You to use standard o[erators with classes that you design.
137
Why is operator overloading useful?
you can perform whatever processing you want in the implementation of the operator overload.
138
Operator overloads look much like standard static method declarations.
T
139
If you overload the true and false operators, then you can use classes in Boolean expressions, such as if(op1){}.
T
140
Assignment operator cannot be overloaded
T
141
What parameter does equals() use
object
142
Where is Icomparable implemented
In the class of the object to be compared.
143
What does the IComparer interface allow?
Allows comparisons between that object and another object.
144
When using Comparer, the types don't have to be comparable.
F
145
Strings are processed in case-sensitive way.
T
146
What does the "as" operator convert?
Converts a type into a specified reference type.
147
You can use the GetType() method to obtain the type of an object, or the typeof() operator to get the type of a class.
T
148
To iterate over a class, implement a method called GetEnumerator() with a return type of IEnumerable.
T
149
What are collections
Classes that can contain instances of other classes.