About QID enthuware.ocajp.i.v8.2.828

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
bniky1
Posts: 4
Joined: Sun Jan 08, 2017 12:27 pm
Contact:

About QID enthuware.ocajp.i.v8.2.828

Post by bniky1 »

There is a question about what line is invalid. According to the answer it is 3 and 4. Why isn't line 2 wrong?? I even tried manually and it failed to compile.

class Test{ }  // 1
public class TestClass {    
public int main(String[] args)  { // 2        
double x=10, double y;  // 3        
System.out.println[]; // 4                 
for(int k =0; k<x; k++){ } //5                 
return 0;    
}
}

This is for Java oca SE8.

Online
admin
Site Admin
Posts: 10055
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About QID enthuware.ocajp.i.v8.2.828

Post by admin »

What do you think is wrong with //2?
Please post the exact code that failed to compile.
If you like our products and services, please help us by posting your review here.

bniky1
Posts: 4
Joined: Sun Jan 08, 2017 12:27 pm
Contact:

Re: About QID enthuware.ocajp.i.v8.2.828

Post by bniky1 »

Error: Main method is not static in class TestClass, please define the main method as:
public static void main(String[] args)

Online
admin
Site Admin
Posts: 10055
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About QID enthuware.ocajp.i.v8.2.828

Post by admin »

This is not a compilation error. This is an error at run time and the error message is quite clear about what is the issue. It is looking for the standard main method. This doesn't mean that the main method that the class has is invalid. It just means that java cannot use that method to execute the class from command line.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: admin and 42 guests