What are a special reference type in C# that provide methods for equality using value semantics and data encapsulation?
Records
What is a user-defined type composed of field data (member variables) and members that operate on this data (C# terminology)?
A class
In the eyes of the C# compiler, what makes the different constructors of a class different?
Number and type of the constructor arguments
What is an instance of a class otherwise known as (C#)?
An object
The power of object-oriented languages allowing you to group data and related functionality in unified class definitions is that it allows you to do what?
Model your software after entities in the real world
What keyword in C# provides access to the current class instance?
this
What methods in C# allow the state of an object to be established at the time of creation?
Constructors
public Car(string pn) => petName = pn;
This C# constructor is an example of what type of member?
An expression-bodied member
What is the "freebie" that every C# class is provided, which never takes arguments, but allows all field data of the class to be set to an appropriate default value, and you can redefine it if you want?
The default constructor
How can you redefine the default constructor of a C# class?
Define a constructor that takes no arguments
Record types in C# are really one specialized type of what?
class
C# supports mutable record types by using standard (not init-only) setters, but record types are really intended to be used for data models that are what?
Immutable
How is a constructor named in C#?
Identical to the class they construct
What is a special method of a class that is called indirectly when creating an object using the new keyword in C#?
A constructor
What is the keyword used to define a class in C#?
class
What is the keyword in C# to allocate an object into memory?
new
What are supported by C# and allow the state of an object to be established at the time the object is created?
Constructors
What is a special method of a class that is called indirectly when creating an object using the new keyword (C#)?
A constructor
What kind of members must be invoked from the class in C# (rather than an object)?
Static
Members of a class deemed to be so commonplace that there is no need to create an instance of a class will be declared as what kind of members (C#)?
Static
What kind of class is a class that does not maintain any object-level state and is never created with the new keyword?
A utility class
What kind of members does a C# utility class expose functionality with?
Static
What are the three pillars of OOP that all object-oriented programming languages must content with?
Encapsulation, inheritance, and polymorphism
What pillar of OOP boils down to the language's ability to hide implementation details from the user?
Encapsulation
What pillar of OOP boils down to the language's ability to allow you to build new class definitions based on existing class definitions?
Inheritance
What is the topmost parent class in any and every class hierarchy in .NET?
System.Object
What pillar of OOP boils down to the language's ability to treat related objects in a similar way?
Polymorphism
What type of member in a C# base class defines a default implementation that may be overriden by a base class?
virtual
What type of member in a C# base class provides only a signature and must be overridden by a derived type?
abstract
In C#, properties, methods, constructors, and fields are all considered what?
Type members
What is the default applied access modifier for a type in C#?
internal
What is the default applied access modifier for a type member in C#?
private
What is a type called when it is declared directly within the scope of a class or structure in C#?
A nested type
The traditional approach to allow interacting with certain private fields of a class is to define 2 methods called what?
An accessor and a mutator
What is the language feature preferred to use for encapsulation over accessor and mutator methods in .NET Core languages?
Properties
What type members in C# are just a container for "real" accessor and mutator methods, named get and set?
Properties
What is the token, or contextual keyword (not a true C# keyword), that can be used within the set scope of a property to represent the incoming value used to assign the property by the caller?
value
How do you make a property read-only in C#?
Omit the set block
How do you make a property write-only in C#?
Omit the get block
What C# feature can be used to streamline a lot of repetitive, basic properties?
Automatic property syntax
What can you type in both Visual Studio and Visual Studio Code (and hit tab twice) to generate starter code for a new automatic property?
prop
What is the shorthand notation offered by C# used to create a class variable using a constructor and then set the state data by property?
The object initialization syntax
Can the object initialization syntax in C# be used to set a property where the property setter is marked private?
No
What keyword does C# offer to define constant data, which can never change after the initial assignment, and the value of which must be known at compile time?
const
Can a constant in C# have its value determined at runtime?
No
Why can the value of a constant in C# not be assigned inside a constructor?
A constructor is invoked at runtime and the value of constant data must be known at compile time
What is the condition for a const string value to use string interpolation in their assignment statement (new in C# 10)?
All the components used must also be const strings
How is a read-only field different from a constant in C#?
A read-only field can have a value assigned at runtime and a read-only field is not implicitly static
What is the keyword in C# that allows a single class to be partitioned across multiple code files?
partial
When defining a class in C# across multiple files, each part must be marked with what keyword?
partial
What is the special reference type that provides synthesized methods for equality using value semantics and data encapsulation in C#?
Record
What is the following equivalent to (C#)?
record CarRecord
record class CarRecord
Defining a record like this in C# removes the need for what property?
record CarRecord(string Color);
public string Color { get; init; }
What method do record types using positional parameters have (a method with an out parameter for each positional parameter in the declaration)?
Deconstruct()
How do record types in C# behave with Equals(), ==, and !=?
They compare like value types
What is the construct in C# that can be used to create a true copy of a record with one or more properties modified?
with
Example:
CarRecord ourOtherCar = myCarRecord with {Model = "Odyssey"};
What are the value type equivalent of record types (new in C# 10)?
Record structs
Previous card
First card
Random order
Next card