Originally posted by gayathri bhushan:
What will happen when you attempt to compile and run the following code?
public class Crowle{
public static void main(String argv[]){
Crowle c = new Crowle();
}
void Crowle(){
System.out.println("Greetings from Crowle");
}
}
1) Compilation and output of the string "Greetings from Crowle"
2) Compile time error, constructors may not have a return type
3) Compilation and output of string "void"
4) Compilation and no output at runtime
Hi everybody,
i need some help out here....the answer for this question is choice 4. I didnt get it.....
the same tutorial said....
You may get questions in the exam that have methods with the same name as the class but a return type, such as int or string. Be careful and ensure that any method you assume is a constructor does not have a return type.
if i follow this then my answer would be choice 2 and not 4.
so, if a function with same name of the class is there should i not assume that it is the constructor of the class and hence it should not have return type and hence it is choice 2. Am i wrong? iam confused....expecting a quick discussion
-gayathri
<UL TYPE=SQUARE><I><LI>Ryan Burgdorfer<BR><LI>Java Acolyte</I></UL>
Don't get me started about those stupid light bulbs. |