70-483 Flashcards
Usage of the volatile keyword
Can be used to indicate that operations involving a particular variable will not be optimized, and the value will be fetched from the copy in memory, rather than being cached in the processor
What does the Parallel.Invoke method do?
Accepts a number of Action delegates and creates a Task for each of them. The method can start a large number of tasks at once
When does the Parllel.Invoke returns?
When all of the tasks have completed
Do we have control over the order in which tasks are started when using Parallel.Invoke method?
No, we don’t have control over the order nor the processor assigned.
How do we use the Parallel.ForEach method?
In the first parameter we add a IEnumerable collection to iterate over. The second parameter provides an Action method to perform on each item in the list.
What’s the difference between struct and class?
- It is not possible to have a parameterless constructor within the structure.
- The struct is used to create value types, the class is used to create reference types.
- The constructor of a structure must initialize all the data members in the structure.
What’s the signature of a method?
The signature defines the type and number of parameters that the method will accept
What is the sequence that is performed when a new instance of a class is created?
- The code that implements the class is loaded into memory, if it is not already present.
- Any static members of the class are initialized(if is the first time that the class has been referenced) and the static constructor is called.
- The constructor in the class is called.
Overload vs overridden methods
Overload means providing a method with the same name but different signatures in any given type and overridden is used when we want that child class can change the behavior of a method from a parent class
Boxing vs unboxing
Boxing refers to the process of converting a value type into a reference type and unboxing refers to the process of converting a reference type into a value type.
Difference between implicit and explicit conversions
TBD
Difference between “is” and “as” operators
The is operator determines whether a given object is in a particular class hierarchy or implements a specified interface, whereas the as operator takes a reference and a type, and returns a reference of the given type, or null if the reference cannot be made to refer to the object
Why do we would use “as” operator instead of casting the object?
When casting an object to a specific type or instance, if the object is not possible to cast it’ll throw an exception, whereas if the as operator fails it returns a null reference and the program keeps running.
What does a sealed class means?
A sealed class means, that this class can not be extended, so it cannot be used as the basis for another class.
Abstract classes
TBD