• Post Reply Bookmark Topic Watch Topic
  • New Topic

simple  RSS feed

 
rabby gail
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would be the results of compiling and running the following class. Select the one correct answer.

class test {
public static void main() {
System.out.println("test");
}
}

The program compiles but does not run.
need explanation

thanks in advance
 
Campbell Ritchie
Marshal
Posts: 56540
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.
The reason your program won't run is that you have the wrong signature for your main method. It needs a String[] parameter, which is usually called args.
 
Keith Lynn
Ranch Hand
Posts: 2409
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The main method you have does not have the correct signature for it to be called when the class is interpreted.

The signature of the main method that will be called by the interpreter is



The method you have is syntactically correct, but the interpreter won't call it.
 
rabby gail
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a lot

by no. of responses
 
wise owen
Ranch Hand
Posts: 2023
 
rabby gail
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks wise 0wen,

still need to know what happens when main is declared as private
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!