Class

A

Ah Ming

Thanks for your response! How about the following classes?

CASE 1:

class ABC {
public int aMethod(int a) {
......
}
private void aMethod(int a) {
......
}
}

CASE 2:

class ABC {
public int aMethod(int a) {
......
}
public void aMethod(int a) {
......
}
}
 
J

Joona I Palaste

Ah Ming said:
Thanks for your response! How about the following classes?
class ABC {
public int aMethod(int a) {
......
}
private void aMethod(int a) {
......
}
}

This should not compile. Method overloading is done by parameters only,
not by return types. Having two methods with the same name and the same
parameters but different return types causes a compile-time error.
class ABC {
public int aMethod(int a) {
......
}
public void aMethod(int a) {
......
}
}

This case is the same as the above.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,281
Latest member
Pedroaciny

Latest Threads

Top