C# Objects Flashcards

1
Q

What does OOP (Object Oriented Programming) mean?

A

It means we can think of a software program as a bunch of distinct objects working together.

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

How do we make our own types?

A

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.

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

When you create a class for an object, what are you really doing?

A

You’re making a template to recreate types or instances of the class. You’re making a “cookie cutter” for this object.

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

What is instantiation?

A

Creating an object from a class.

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

How do you create a new instance/object of a class?

A

with the new keyword.

Tower tower = new Tower();

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

Should you include as MANY or as FEW attributes to a class when you are thinking about what to add to it?

A

Keep them as minimal as possible while maintaining all necessary functionality.

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

What is a private field?

A
Private fields are only accessible to methods
in the same class that they're declared in.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is a public field?

A

Public fields, on the other hand, can be accessed by any method in any class.

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

What is an access modifier keyword?

A

A keyword that you can associate with a field to assign the level of access that other methods have to it.

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

If you dont specify an access modifier keyword, what will it be assigned to be default?

A

Private.

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

What is a constructor method?

A

A method inside of your object class that is used to construct new instances of the class.

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

How should you name constructor level variables?

A

Beginning with a lower case letter.

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

How should you name the constructor method itself?

A

Give it the same name as the class.

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

What is the main purpose of a constructor method?

A

To give the class some initial values.

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

How do you make a field “Read Only” and why does that matter?

A

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.

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

What do you have to do in order to make your constructor usable by other classes?

A

Give it the public access modifier keyword.

17
Q

When are you allowed to set a read only field?

A

Only during object construction.

18
Q

Can constructs return a value?

A

No.