Log in

View Full Version : What's the Signature of an Operation in Java?


FranceBB
1st November 2020, 05:13
Hi there.
Sorry to bother you all, but the professor just gave us some assignments (as he always does), but this time it's like 59 pages worth of multiple choices questions and other open questions that we have to answer ourselves. One of those is:

"What's the Signature of an Operation in Java? Make an example"

Now... what the heck does he mean with Operation?
Does he mean "method"? 'cause I know what a Signature of a Method is, but I couldn't find anything anywhere about the Signature of an Operation in Java and the slides (PDF) don't really help either.
AFAIK a Signature is a declaration of a method with a return type, the name of the method, the type and the name of (eventual) parameters passed as input. Generally, the definition of a method uses the same syntax used for the procedures with some additional indicators that make the encapsulation of information possible.
An example would be:

public void setMapPointerReference(int x, int y)
{
//code of the method
}

The Signature, in this case, would be "SetMapPointerReference(int x, int y)".
In other words, it's the name of the method and the list of the parameters.

Did I get it right? Is it the same for operations? Does he mean method when he says operations? Can you make an example?

Thank you in advance,
Frank

StainlessS
1st November 2020, 12:45
No idea but google "Java" "Signature" "Operation" "method"

https://www.google.co.uk/search?ei=S6CeX9eYIsXDxgOzoaD4BQ&q=%22Java%22+%22Signature%22+%22Operation%22+%22method%22&oq=%22Java%22+%22Signature%22+%22Operation%22+%22method%22&gs_lcp=CgZwc3ktYWIQAzoECAAQRzoICCEQFhAdEB5Qhx9Y_31g4YEBaABwAngAgAH7AYgBrwuSAQUzLjguMZgBAKABAaoBB2d3cy13aXrIAQjAAQE&sclient=psy-ab&ved=0ahUKEwiX6qOLo-HsAhXFoXEKHbMQCF8Q4dUDCAw&uact=5

LoRd_MuldeR
1st November 2020, 15:09
I'm not sure "operation" is common Java jargon. Maybe here "operation" just means method? Or it is a typo and it was supposed to be "operator" :confused:

Anyway, I'd say that the signature of a Java method is the method's name plus its parameter list. That's because Java supports overloading, so we can have multiple methods with the same name - as long as their parameter lists differ. So, the parameter list obviously is a part of the signature. The return type may not be considered a part of the signature, because methods of the same name differing only in the return type (but not in the parameter list) are not allowed in Java.

StainlessS
1st November 2020, 15:15
I'm not sure "operation" is common Java jargon. Maybe here "operation" just means method? Or it is a typo and it was supposed to be "operator" :confused:


Probably just intends bamboozling alternative to the word Method. [meaning method without actually saying the word Method]

Kinda 'tricky' your professor.

FranceBB
1st November 2020, 15:48
Anyway, I'd say that the signature of a Java method is the method's name plus its parameter list. That's because Java supports overloading, so we can have multiple methods with the same name - as long as their parameter lists differ. So, the parameter list obviously is a part of the signature. The return type may not be considered a part of the signature, because methods of the same name differing only in the return type (but not in the parameter list) are not allowed in Java.

Got it. So I can have the same method with different parameters and then pick the one I need, so that's why Signatures are needed, to differentiate them based on their parameters. Understood.

Probably just intends bamboozling alternative to the word Method. [meaning method without actually saying the word Method]

Kinda 'tricky' your professor.

Yeah, I think so. It wouldn't be the first time that he writes something meaning something else xD
In all fairness to him, though, since we're all not Native English Speakers in the class and that courses are not in English, he probably thought that some word would be easier to understand than others, while in fact they only ended up creating confusion like in this case.

Anyway, thank you both! :)