overloading Flashcards

1
Q

overloading

A

allows methods to have the same name in the same class

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

how java determines which method to call when multiple methods have the same name

A

it is based on the method signatures

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

signature

A

name, static or instance, parameters (not return type) (what about visability modifier?)

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

what is the signature for this:

public float doSomething(intx);

A

doSomething(int)

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

prototype of a method

A

signature with a return type and any additional modifiers

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

parameter type promotion

A

if you give java an integer when it expected a double (or anything more precise), it will promote the integer to a double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
public voidfooBar( intx, doubley ) { … } 
public voidfooBar( doubleu, intv ) { … } …
A

fooBar( 10, 23.0 );// okay, use the first
fooBar( 10.0, 23 );// okay, use the second
fooBar( 10, 23 ); // java does not know which int to promote (compile-time error)

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