methods & overloading Flashcards
(10 cards)
What is method overloading?
Using the same method name with different parameters.
Write overloaded method to calculate area of a circle.
public double CalculateArea(double r) { return 22 / 7 * r * r; }
Overloaded method for rectangle area?
public double CalculateArea(double l, double w) { return l * w; }
Overloaded method for triangle area?
public double CalculateArea(double b, double h, bool isTriangle) { return 0.5 * b * h; }
Difference between parameter and argument?
Parameter: in method definition; Argument: value passed in call.
Difference between function and procedure?
Function returns a value, procedure does not.
Difference between overriding and overloading?
Overriding is in inherited classes, overloading is in the same class.
How to call a method from another class?
new ClassName().MethodName();
What is the return type of method GetAmountDue?
Double
What value is returned by GetAmountDue(25) if rate is 15, VAT 12%?
375