Author Topic:   Jargon
Indy
greenhorn
posted April 29, 2000 10:06 PM             
I am doing the Jargon simulator. However, in the test, I found, all the main method was starting with "static public...", and always a void return type before the constructor--obviously they are not testing me how to distinguish a constructor from a method. What's going on there? Anyone else has the same confusion?

BY the way, is there anyone, who is going to take the test soon, would like to exchange emails with me about more details on mock tests? Impossible to put all the doubts about test on here. Looking forward to get any response. my email add is:
sakula@hotmail.com

Indy

Tony Alicea
sheriff
posted April 30, 2000 01:14 PM             
Constructors are not methods. Methods need a return type (like void or int). Constructors do not have an explicit return type since they always return a type of their class.

For example new String() returns what the name of the constructor is, a String.

And static public is the same as public static. The return type (like void) has to go right before the method name, though.

Indy
greenhorn
posted April 30, 2000 02:51 PM             
Thanks Tony. I just find out "static public" is legal too, as "public static" is.

I know that constructors should NOT have return type. WHat I was asking is, in Jargon, I found some members which obviously are contsructors have a "void" ahead. (answers are reasoned by assuming they are construtors) Or, I misread. I will go back to check again. If no one is complaining about this, I would be wrong.

Indy

maha anna
bartender
posted April 30, 2000 04:18 PM             
Indy,
Can you post the exact qstn here? What I think is,
There can be a legal method whose name is same as the class in which it is defined and it's return type may very well be void

Also note that when the user DOES NOT DEFINE any constructors, the compiler will provide one for you. This may be the case also in the qstn you pointed out. The foll is a legal class.



class Test {
void Test() {

}
}

regds
maha anna

|