C# Objects Flashcards
What does OOP (Object Oriented Programming) mean?
It means we can think of a software program as a bunch of distinct objects working together.
How do we make our own types?
A class is the template for making individual objects of a particular type.
Each individual object that a class makes is called an instance of that class.
Remember we can use the words type and class interchangeably.
When you create a class for an object, what are you really doing?
You’re making a template to recreate types or instances of the class. You’re making a “cookie cutter” for this object.
What is instantiation?
Creating an object from a class.
How do you create a new instance/object of a class?
with the new keyword.
Tower tower = new Tower();
Should you include as MANY or as FEW attributes to a class when you are thinking about what to add to it?
Keep them as minimal as possible while maintaining all necessary functionality.
What is a private field?
Private fields are only accessible to methods in the same class that they're declared in.
What is a public field?
Public fields, on the other hand, can be accessed by any method in any class.
What is an access modifier keyword?
A keyword that you can associate with a field to assign the level of access that other methods have to it.
If you dont specify an access modifier keyword, what will it be assigned to be default?
Private.
What is a constructor method?
A method inside of your object class that is used to construct new instances of the class.
How should you name constructor level variables?
Beginning with a lower case letter.
How should you name the constructor method itself?
Give it the same name as the class.
What is the main purpose of a constructor method?
To give the class some initial values.
How do you make a field “Read Only” and why does that matter?
by using the readonly keyword. (it is entered before the field’s type declaration.)
If you want to make sure that the info remains unedited by any other methods, do this.