methods & overloading Flashcards

(10 cards)

1
Q

What is method overloading?

A

Using the same method name with different parameters.

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

Write overloaded method to calculate area of a circle.

A

public double CalculateArea(double r) { return 22 / 7 * r * r; }

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

Overloaded method for rectangle area?

A

public double CalculateArea(double l, double w) { return l * w; }

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

Overloaded method for triangle area?

A

public double CalculateArea(double b, double h, bool isTriangle) { return 0.5 * b * h; }

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

Difference between parameter and argument?

A

Parameter: in method definition; Argument: value passed in call.

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

Difference between function and procedure?

A

Function returns a value, procedure does not.

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

Difference between overriding and overloading?

A

Overriding is in inherited classes, overloading is in the same class.

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

How to call a method from another class?

A

new ClassName().MethodName();

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

What is the return type of method GetAmountDue?

A

Double

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

What value is returned by GetAmountDue(25) if rate is 15, VAT 12%?

A

375

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