Overloading Flashcards

1
Q

TRUE OR FALSE
No two methods or constructors in the same class may have identical signatures.

A

True

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

Methods are distinguished by their _______.

A

Methods are distinguished by their signature:
- different number of arguments
- different data type of arguments
- different arrangement of parameter

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

Why is the following considered to be VALID for overloading?
void Addme( int x , int y)
void Addme(int x, int y, int z)

A

Different number of arguments

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

Why is the following considered to be VALID for overloading?
void Addme( char x , char y)
void Addme(char x, int y)

A

Different data type of arguments

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

Why is the following considered to be valid for overloading?
void Addme( char x , int y)
void Addme(int x, char y)

A

Different arrangement of parameter

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

Why is the following NOT considered valid for overloading?
void Addme( int x , int y)
void Addme(int num1, int num2)

A

Same data type

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

Why is the following NOT considered valid for overloading?
void Addme( int x , int y)
void GetSum(int y int x, int z)

A

The method names are different

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

How do you call one constructor in another constructor?

A

You can call one constructor in another constructor by using the this keyword

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

A feature of Java in which a class has more than one method of the same name and their parameters are different.

A

Overloading

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

What is the method signature of the following method header?
void Area (int length, int width)

A

Area (int, int)

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