Classes Coding Questions Flashcards

1
Q

Write a field constructor

A

public ClassName (type + variableName)
{
variable = Variable;
Etc. weight=Weight;
}

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

Write a constructor

A

public ClassName ()
{
variable = appropriateValue;
Etc. weight =0;
}

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

Write GET and SET

A

public type NameOfVariable()
{
get {return nameOfVariable; }
set {nameOfVariable = value; }
}

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

Class Hamper
double hamperWeight;
char nextDayDelivery;
How to instantiate an object?

A

Hamper hamper = new Hamper ( hamperWeight, nextDayDelivery)

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

Define an array called artWorksArray that is capable of holding details for 50 items of ArtWork.

A

ArtWork [] artWorksArray = new ArtWork[50];

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

How to write a constant variable?

A

private const type variableName = value;
Etc. double hourlyRate = 20;

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