C# Classes / Objects / Inheritance Flashcards
What does overloading constructors mean?
Overloaded constructors enable objects of a class to be conveniently initialized in different ways. To overload constructors, simply provide multiple constructor declarations with different signatures.

What is the special use case for the this keyword to prevent code duplication for constructor overloading?

What is a common gotcha when dealing with constructors?

What is a constructor initializer?
: this(time.Hour, time.Minute, time.Second) { }
This is called a constructor initializer. Enables a class to reuse initialization code provided by a constructor, rather than defining similar code in another constructor.
What is the nameof operator?
It’s common to include in an exception’s error message a variable’s or property’s identifier. As of C# 6, you can instead use the nameof operator, which returns a stringrepresentation of the identifier enclosed in parentheses.

What is garbage collection and what are destructors?

What are readonly Instance variables?

When should you use readonly over const?

When to use const over readonly?

How do you auto implement getter property and readonly?

What is the object browser?

What is the object initializer syntax look like when there is no perfect constructor for your needs but the instance variables are there?

What is operator overloading?
You can create operators that work with objects of your own types — via a process called operator overloading. You can overload most operators!
What is a Struct and when should you use one over a class?

What would overloading an operator in a stuct look like?

What would overloading the - and * operators look like?

What can’t you do with a struct?

What keyword is used to overload operators?

Can you overload an operator method for two different types?

What are extension methods?

What is inheritance?
Inheritance allows a new class to absorb an existing class’s member. A derived class normally adds its own fields and methods to represent a more specialized group of objects. Inheritance saves time by reusing proven and debugged high-quality software.
What is a direct base class?
The direct base class is the base class which the derived class explicitly inherits
What is an indirect base class?
An indirect basae class is any class above the direct base class in the class hierarchy. The class hierarchy begins with class object.
Which type of relationship represents inheritance?
The is-a relationship
eg. a car “is a” vehicle
a dog “is a” specialized kind of mammal
What are the differences between base classes and derived classes?
Base classes are “more general” (mammal) and derived classes are “more specific” (cat)

What would a UML diagram of the relationships of the base/derived classes look like?

What are some characteristics and uses of base/derived classes?

What are protected members?

What to use private or protected fields?

How to use lambda functions to create methods in a class?
Look at the arrow function syntax.

Can you change the access modifier when overriding a method?

Best way to create variable that only need to be get?
First initialize the values in the constructor then do a property with get only auto generated;

Best way to create and use an instance variable that needs get and protected set?
first create private instance variable, then a property that gets and protected sets.

What does DRY mean?
Dont Repeat Yourself
What would constructor (passing) look like?
**cant remember the name **

What do the virtual and abstract keywords do?

Where can using protected instance variables cause problems?

What is the base. method invocation and when should it be used?

How do constructors in derived classes work?

What are the main benefits to inheritance?

What does the ToString method do?

What does the Reference-Equals method do?

What does the Memberwide-Clone method do?

What does the GetType method do?

What does the GetHashCode method do?

What does the Finalize method do?

What does the Equals method do?
