General C# programming - Creating New Classes Flashcards

1
Q

How would you create a new class called Weapons?

A

class Weapons { }

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

How would you set a new string property in the weapons class called Gun?

A

public string Gun {get;set;}

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

How would you set a new int property in the Weapons class called Ammo;

A

public int Ammo {get;set;}

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

How would you creat a new instance of the Weapons class in a seperate class?

A

Weapons myWeapon = new Weapons();

myWeapon = anything you want to name it.

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

How would you set the number of ammo from the Weapons class inside another class?

A

myWeapon.Ammo = 22;

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

What does the word abstract in the follow class mean?

abstract class Inventory{

}

A

The class is intended only to be a base class of other classes

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

what does sealed mean in the following example?

sealed class B {

}

A

prevents other classes from inheriting from it

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

override

A

extend or modify the abstract or virtual implementation of an inherited method, property, indexer, or event.

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