Coding Global Background
Coding Global

ap csa java question

Archived 2 years ago
4 messages
0 members
Created 2 years ago
Updated 2 years ago
Open in Discord
T
techno
 class Overload

{

public int average(int x, int y)

{ /* implementation not shown */ }

 

public int average(int value1, int value2)

{ /* implementation not shown */ }

 

// There may be instance variables, constructors,

// and methods that are not shown.

}

II.

public class Overload

{

public int average(int x, int y)

{ /* implementation not shown */ }

 

public int average(int x, int y, int z)

{ /* implementation not shown */ }

 

// There may be instance variables, constructors

// and methods that are not shown.

}

III.

public class Overload

{

public int average(int x, int y)

{ /* implementation not shown */ }

 

public int average(double x, double y)

{ /* implementation not shown */ }

 

// There may be instance variables, constructors,

// and methods that are not shown.

}


Which of the attempts at method overloading will compile without error?

A
I only

B
II only

C
III only

D
II and III only

E
I, II, and III

The answer is D I dont understand why 3 will compile since the paramters in the average method are different data types

Replies (4)