Omni Flashcards

(202 cards)

1
Q

What is a Delegate?

A

A way of passing behavior as a parameter

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

What are Default Constructors?

A

Methods that don’t return anything or take any parameters

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

What are Static Members shared between?

A

Static Members are shared between Instances of a Class

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

What is a Model?

A

A Model is an abstraction of something

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

What does the “new” keyword do?

A

It allocates memory at run time

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

What is Inheritance?

A

If a Class B inherited from Class A then it contains all characteristics (information structure and behavior) of Class A

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

What is a naive way of writing code line by line?

A

Procedural Programming

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

What is Error Handling?

A

Error Handling is the term for all techniques involving Finding and Correcting Errors

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

What are the 3 categories that Operators can be divided into?

A

Unary, Binary, and Ternary

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

What is the term for a variable in a Struct?

A

a Data Member

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

In C#, what is a Field?

A

A Field is a Variable of any type that is declared directly in a Class or Struct. Fields are Members of their containing type.

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

What is the difference between a Function and a Method?

A

A Method is a special type of function with an Implicit Argument Passed (an instance of the class that the method is defined on). This is important, as a Function, in strict terms, should not use or modify anything not in its argument list

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

Where can you access Private Members from?

A

Only from Inside the Class

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

Yes

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

Can you instantiate an Abstract class?

A

No

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

What is the “Diamond Problem”?

A

In multiple Inheritance, if intermediate classes inherit from same base class then the 3rd level of child class will have the same behavior from two classes

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

What is Association in OOP?

A

Object interaction with each other is called Association

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

What are the 2 main types of Association?

A
  • Class association (inheritance)

- Object association (simple association, composition, aggregation)

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

What is the difference between “.” and “->” ?

A

The dot operator “.” accesses type through name

The arrow key operator “->” accesses type through a pointer

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

What is the purpose of the scope resolution operator?

A

If you declare a Function inside a Class and define it Outside the Class then you need to use the Scope Resolution Operator “::”

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

What is a Constructor?

A

A Constructor is used to Initialize the Objects of Class. The Constructor is automatically called when the Object is Created. It does not have return type.

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

What is a Destructor?

A

A Destructor is used to free the memory that is allocated through dynamic memory allocation. It destroys an object when it goes out of scope. Destructors use “~” as prefix

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

Can Destructors be overloaded?

A

Yes

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

How is a Destructor called?

A

In reverse order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are Accessors?
Accessors are used to access data members that are defined as private.
26
Name four Integer Types
Byte, Short, Int, Long. All are also available in Signed and Unsigned versions.
27
Can Interfaces exist on their own?
No
28
What is an Interface?
A collection of Private instance Methods and Properties that are grouped together
29
What does the term Inheritance mean in OOP?
Inheritance is when one class inherits all the Members of another class
30
What is a Struct?
Data structures that are composed of several pieces of data, possibly of different types
31
In C#, all Classes are derived from what?
The Base Class Parent at the Root of the Class, and ultimately System
32
What are Non-default Constructors?
Non-default Constructors are Constructors that include Default Parameters
33
What does Polymorphism allow?
All Objects Instantiated from a Derived Class can be Treated as if they were Instances of a Parent Class
34
Are Protected Members accessible anywhere?
No, only from code that is either part of the Class or a Derived Class
35
Are Public Members accessible anywhere?
Yes
36
Within a Class definition, do all Members have the same accessibility levels?
No
37
Which Keyword makes Members Accessible only from code within the assembly (project) where they are defined?
Internal
38
What are the 4 Class Definition Modifiers for accessibility?
Public, Private, Internal, and Protected
39
Why would you use the Global keyword?
If you have a conflict between a Class Name and a Namespace, for example, you can use the Global keyword to access the Namespace
40
If Override is used, can sealed also be used to specify that no further modifications can be made to this method in derived classes?
Yes
41
Can Accessors be used to control the access level of the Property?
Yes
42
Accessors are defined using what keywords?
Get and Set
43
What does the Override modifier do?
The Override Modifier is required to extend or modify the Abstract or Virtual implementation of an Inherited Method, Property, Indexer, or Event
44
What is Inheritance in classes?
If a Class B inherited from Class A then it contains all the characteristics (information structure and behavior) of Class A
45
What is Generalization?
Generalization means multiple Classes can Inherit the same Attributes from the parent Class
46
A Generalization of Cats and Dogs could be? A. Tabby B. Mammals C. Yellow Lab D. Fur
Mammals
47
A Specialization of Fish could be? A. Under Water B. Animals C. Whales D. Tuna
Tuna
48
What is Containment?
When one class contains another
49
What is the base class in C#?
System
50
Abstract classes can possess what kind of members?
Abstract Members and Non-Abstract Members.
51
Can Abstract Classes contain Members that can be Inherited by a Derived Class?
Yes
52
Can Interfaces contain Members that can be Inherited by a Derived Class?
No
53
When you assign an object to a variable, are you actually assigning that variable with a pointer to the object to which it refers?
Yes
54
What does passing a parameter by reference mean?
The referenced variable will be used each time a function is run rather than using a constant number
55
A Full Copy is referred to as what?
A Deep Copy
56
What is the term for the .Net method of freeing up unused memory?
Garbage collection
57
Properties contain a Type Name, a Property Name, and one or both kind of Blocks?
Get and Set
58
Do you have to use an Accessor to make a Property useful?
Yes
59
Do Properties use the same keywords as Fields and Methods?
Yes
60
What does the keyword "value" refer to?
Equates to a value of the same type as the property
61
Is Refactoring usually done by hand, or with a tool?
A tool
62
What is Refactoring?
Code Refactoring is the process of Restructuring existing computer code, Without changing its external Behavior
63
What is an Object?
A collection of Variables and possibly Functions
64
Is the main limitation of Automatic Properties that they must include both a Get and Set Accessor?
Yes
65
When you inherit a Non-Abstract Member from a Base Class, do you also inherit an Implementation?
Yes
66
Why are Properties the preferred way to access the State of an Object?
They shield external code from the implementation of data storage within the object
67
With an Automatic Property, you declare what?
A Property with a simplified syntax
68
When a Base Implementation is hidden, how can you still access it?
By using the Base keyword
69
Can you define Types such as Classes in Namespaces?
Yes
70
Can you define Types inside other Classes?
Yes
71
Is the most useful function of the Base keyword the capability to pass a reference to the current Object instance to a method?
No
72
Like Base, this refers to an Object instance, although it is a Future Object instance
No
73
What does the "this" keyword refer to?
An Object Instance
74
How do Implicit and Explicit Conversions differ?
Implicit: conversion is possible in all circumstances, and the compiler can do it. Explicit: conversion is possible only in certain circumstances
75
What is the keyword "this" used for in C#?
To pass a reference of the current object instance to a method
76
What type of language is C#?
a Strongly Typed, Block-Structured language
77
Are Interface Members have implementations (bodies)?
No
78
Can Interfaces can contain code bodies?
No
79
Why would you want to use the "new" keyword in defining Interface Members?
If you want to hide Members inherited from base Interfaces
80
A Class that implements an Interface Must Contain implementations for All Members of that Interface
Yes
81
Do Interface values specify how the property data should be stored?
No
82
It is possible to Implement Interface Members using the keyword Virtual or Abstract?
Yes
83
Is it true Interface Members cannot be Implemented Explicitly by a Class?
No
84
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?
Yes
85
How do you declare an array?
"[ ]"
86
What is the code that allows fields to expand and contract?
#region and #endregion
87
In what two forms can you copy the Constructor?
Deep Copy | Shallow Copy
88
What is the difference between a Class variable and an Instance variable?
Class variables only have one copy that is shared by all the different objects of a class, whereas every object has it’s own personal copy of an instance variable. So, instance variables across different objects can have different values whereas class variables across different objects can have only one value.
89
Can Static Methods be instantiated?
No
90
What is a Deep Copy?
If an object has pointers to dynamically allocated memory, and the dynamically allocated memory needs to be copied when the original object is copied, then a Deep Copy is required.
91
What is a Shallow Copy?
A Shallow Copy of an object copies all of the member field values.
92
It is possible to Implement Interface members using the keyword Static or Const?
No
93
Can Overloading effect Associativity?
No
94
Are Unary operators and Assignment operators right or left associative?
Right
95
What is an Explicit Conversion or Cast?
Casting is required when information might be lost in a conversion from one type to another, or when the conversion might not succeed for other reasons. A typical example would be numeric conversion to a type that has less precision or a smaller range. float x = 3.25; int y = (int)x; // y == 3
96
How would you Cast "x" as an int?
(int)x
97
What is the goal of Object Oriented Programming?
Modularity and Extensibility
98
Write code using a Ternary Operator that sets x equal to y if x is greater than y, or sets x equal to b if x is less than or equal to y
x > y ? x = y : x = b
99
In .NET, do you immediately create operating system-specific native code, or do you compile into Common Intermediate Language code?
Common Intermediate Language code
100
What are Collection classes used for in general?
Maintaining lists of objects
101
What keyword can you use to declare a variable without specifying a data type explicitly?
var
102
Are strings Immutable in C#?
Yes
103
Can you apply Access Modifiers to Interface Members?
No
104
What would the code look like where a FileInfo class implements an IFile interface?
class FileInfo : IFile
105
What keyword would you use to split a Method?
partial
106
How might a partial class definition be used?
Put the fields, properties, and constructor in one file, and the method in another
107
Can a Method be split between files?
Yes. Using partial
108
Can Partial Methods be static?
Yes
109
Must a Class that implements an Interface implement all of the Members defined by that interface?
Yes
110
A Class that Implements an Interface must implement the members with what modifier?
Private
111
What are some restrictions Partial methods have?
No return value, No out parameters
112
Properties and Methods can be defined as ______ or ______ in Base Classes to define Inheritance
Abstract or Virtual
113
What do Collections enable you to maintain?
Groups of Objects
114
What is the Ternary Operator syntax?
condition ? do if true : do if false
115
How would you declare a "x" as a nullable int?
int? x
116
Why not to use "var" everywhere?
"var" isn't a performance hit, but it can make code harder to understand. "var" obscures the actual variable type, so if the initializer doesn’t return a clearly defined type then you may not be able to tell the what type of data you're dealing with
117
How would you declare a function called "MyFunc" with a nullable boolean parameter named "flag"?
MyFunc (bool? flag) { }
118
How would you declare a function called "EvalPi" with a parameter of type double called "input" that has a default value of "3.14"?
EvalPi (double input = 3.14) { }
119
Which type of Case should you use to name a Method or Function in C#? ``` A. Camel Case B. Snake Case C. Pascal Case D. _lowerCamelCase E. Kebab Case F. lowerCamelCase ```
C. Pascal Case
120
Which type of Case should you use to name a Namespace in C#? A. Camel Case B. Snake Case C. Pascal Case D. Kebab Case
C. Pascal Case
121
What is the best practice for naming Interfaces in C#?
Start the name with an upper case "I", followed by Pascal Case. For example, "IMyInterface"
122
Which type of Case should you use to name a Private Field in C#?
_lowerCamelCase
123
Which type of Case should you use to name a Local Variable in C#?
lowerCamelCase
124
Which type of Case should you use to name a Parameter in C#?
lowerCamelCase
125
Which Member has an Accessibility, Return Type, and Parameters?
Fields
126
Declare a pointer variable x, which can hold the address of an int type
int *x
127
Assign the memory address of x to a pointer variable
int *ptr = & x; Console.WriteLine((int)ptr) // Displays the memory address Console.WriteLine(*ptr) // Displays the value at the memory address.
128
What is the C# name for a Destructor?
A Finalizer
129
Can Finalizers be defined in Structs?
No
130
How many Finalizers can a class have?
1
131
Can Finalizers be inherited?
No
132
Can Finalizers be overloaded?
No
133
Can a Finalizer be called?
No
134
Does a Finalizer take modifiers or have parameters?
No
135
How would you write Auto Implemented Properties for a public property called "Name" of type String?
public string Name { get; set; }
136
Do you have to instantiate an Object to make use of a Static Class?
No. In fact, you can't
137
What kind of linkage does the keyword Static create?
Internal
138
If the keyword Static is used outside of a class, what does that do?
That function's scope is limited to the file where it is declared. It can't be exported, or called elsewhere
139
How would you create a list of type string?
List
140
What does the Abstract Keyword enable you to do?
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class
141
Can an Abstract class be instantiated?
No
142
How many Base Classes can a Class have?
1
143
What is Lazy Initialization of an object?
Assume you have property that contains a large array of objects that, to be initialized, requires a database connection. If the user never asks to display the Orders or use the data in a computation, then there is no reason to use system memory or computing cycles to create it.
144
What is a wrapper class that provides lazy initialization for any class library or user-defined type?
Lazy
145
What is Caching?
If you have an expensive object, you save it to process memory and reuse it, instead of running the code to produce it over and over
146
What types of relationships are in OOP?
Is-a and Has-a
147
Another name for a Parent Class could be a?
Super Class
148
Another name for a Child Class could be a?
Sub Class
149
What does the keyword "virtual" allow?
For a method to be overrideable when it's inherited
150
What Keyword is used to make a method behave differently in a sub class than in its super class?
override
151
Can an Abstract Method declare a body (or block) ?
No
152
Can a Virtual Method declare a body (or block) ?
Yes
153
What is another name for a non-abstract class?
A concrete class
154
What type of class MUST be overridden, Abstract or Virtual?
Abstract
155
What is Polymorphism?
How we change the behavior of the base class when we create a sub class
156
What is a Class Hierarchy?
The design, or topology, of how classes are inherited from other classes
157
What are the three pillars of OOP?
Polymorphism, Encapsulation and Inheritance
158
What Keyword can we use to re-use the name of a method in the base class in the sub class for a different purpose?
new Bonus: This is called Hiding
159
What is Client Code?
Some methods and properties are meant to be called or accessed from code outside a class or struct
160
Classes may be declared as _______, which means that one or more of their methods have no implementation
abstract
161
True or False, to inherit from an interface means that the type implements all the methods defined in the interface
True
162
What does the Keyword Static do?
One copy of the class is loaded into memory when the program loads, and its members are accessed through the class name
163
Can you instantiate and initialize class or struct objects, and collections of objects, without explicitly calling their constructor?
Yes
164
What are Anonymous Types?
Anonymous types provide a convenient way to encapsulate a set of read-only properties into a single object without having to explicitly define a type first. The type name is generated by the compiler and is not available at the source code level. You create anonymous types by using the new operator together with an object initializer. "var" is almost always used
165
What is an Extension Method?
You can "extend" a class without creating a derived class by creating a separate type whose methods can be called as if they belonged to the original type
166
What are Generics?
Generics make it possible to design classes and methods that defer the specification of one or more types until the class or method is declared and instantiated by client code. For example, by using a generic type parameter T, you can write a single class that other client code can use without incurring the cost or risk of runtime casts or boxing operations
167
What does passing a parameter by reference mean?
Passing a parameter by reference means the referenced variable will be used each time a function is run rather than making a copy of the variable, such as with a value type
168
What are some differences between Arrays and Collections?
Unlike Arrays, Collections can Control Access to the objects they contain, Search and Sort, and more
169
What does the Sealed Keyword do?
The Sealed Keyword enables you to Prevent the Inheritance of a Class Or certain class Members that were previously Marked Virtual
170
Where is a Class stored in memory?
On the Heap
171
Where are Structs stored?
On the Stack
172
Typically, which is smaller, the Stack or the Heap?
The Stack
173
Write a foreach loop that uses regex to look for the word "you" in a string named input
foreach(Match m in Regex.Matches(input, "you")) {}
174
What is IL?
Intermediate Language code. It is a partially compiled code
175
What is JIT?
Just In Time compilation. In C#, JIT compiles IL into machine language
176
Is it possible to view IL code?
Yes, by using a Disassembler, such as DASM
177
Why do we need to compile into IL first? Why not directly to machine code?
The developer environment and the runtime environment can be very different. You may develop on Windows 10, but the code may be run on Mac, for example. Intermediate Language can be compiled into almost any platform
178
What language must you code a .NET project in?
Trick question. You can code a .NET project in several languages.
179
What is the importance of CLR?
Common Language Runtime invokes IL to compile into Native code. Also, Garbage collection is done in the CLR
180
What is unmanaged code?
Code that is imported, and used as is, that is not under the control of the CLR. Unmanaged code has its own environment and runtimes. Importing .dll's that were written in C++ is one example
181
Does garbage collection run on unmanaged resources?
No
182
What is CTS?
Common Types System. It ensures that data types created in different languages get compiled to a common data type.
183
What is CLS?
Common Language Specification. A set of guidelines that helps ensure any program written in a .NET language can be consumed by .NET CLR. Rules for different data types, use of pointers, functional programming, etc
184
When an object is instantiated, is it's pointer stored on the Heap or the Stack?
The Stack
185
Where is the data, or values, of an object stored? Heap or Stack?
Heap
186
How are Value Types stored as far as the Stack and the Heap are concerned?
With Value Types, the value and the pointer are both stored on the Stack. int, bool, etc
187
How are Reference Types stored as far as the Stack and the Heap are concerned?
With Reference Types, the the pointer is stored on the Stack, however the value(s) are stored on the Heap. string, objects, etc
188
What is Boxing?
Moving a Value Type to a Reference Type
189
What is Unboxing?
Moving a Reference Type to a Value Type
190
What is the problem with Boxing and Unboxing?
Performance. It's expensive to move data around, especially from Stack to Heap.
191
What is an Array?
An Array is a data structure of a series of data of the same type. It is a specific contiguous location in memory and it has a fixed length. (technically yes, an array can be resized, but this is expensive)
192
What is an ArrayList?
Flexible length, can mix and match different types
193
What two data types do you get the best of with Generics?
Arrays and Lists
194
What is Threading in a simple sense?
When you want to run processes in parallel, or more than one process at a time
195
How would you create a variable named v with an anonymous type of Amount = 108 and Message = "Hello"
var v = new { Amount = 108, Message = "Hello" };
196
What is the Big O notation for Binary search?
O(log n)
197
What is the Big O notation for Simple search?
O(n)
198
What is the Big O notation for Quicksort?
O(n * log n)
199
What is the Big O notation for Selection Sort?
O(n^2)
200
What is the Big O notation for Traveling Salesperson?
O(n!)
201
What's 1 example of a possible problem with Hash Tables?
Collisions
202
What is a common way of dealing with Collisions in Has Tables?
Chaining