Overloading Flashcards
TRUE OR FALSE
No two methods or constructors in the same class may have identical signatures.
True
Methods are distinguished by their _______.
Methods are distinguished by their signature:
- different number of arguments
- different data type of arguments
- different arrangement of parameter
Why is the following considered to be VALID for overloading?
void Addme( int x , int y)
void Addme(int x, int y, int z)
Different number of arguments
Why is the following considered to be VALID for overloading?
void Addme( char x , char y)
void Addme(char x, int y)
Different data type of arguments
Why is the following considered to be valid for overloading?
void Addme( char x , int y)
void Addme(int x, char y)
Different arrangement of parameter
Why is the following NOT considered valid for overloading?
void Addme( int x , int y)
void Addme(int num1, int num2)
Same data type
Why is the following NOT considered valid for overloading?
void Addme( int x , int y)
void GetSum(int y int x, int z)
The method names are different
How do you call one constructor in another constructor?
You can call one constructor in another constructor by using the this keyword
A feature of Java in which a class has more than one method of the same name and their parameters are different.
Overloading
What is the method signature of the following method header?
void Area (int length, int width)
Area (int, int)