About Question enthuware.ocajp.i.v7.2.992 :

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

Moderator: admin

Post Reply
Nisim123
Posts: 42
Joined: Mon Jan 20, 2014 2:26 pm
Contact:

About Question enthuware.ocajp.i.v7.2.992 :

Post by Nisim123 »

It says that the right answer is:
The program will print no arguments and 1 arguments when called with zero and one arguments.
Is there any possible way to run a java file with no argument and 1(as an argument) at the same time?
:?

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

Re: About Question enthuware.ocajp.i.v7.2.992 :

Post by admin »

No, it will print "no arguments" when run with zero argument and "1 arguments" when run with one argument.
If you like our products and services, please help us by posting your review here.

Nisim123
Posts: 42
Joined: Mon Jan 20, 2014 2:26 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.992 :

Post by Nisim123 »

Thanks, it is probably the way the sentence is set (from the grammatical POV...) that confused me....
:oops:

JavaLegend
Posts: 1
Joined: Sun Dec 20, 2015 11:46 pm
Contact:

Re: About Question enthuware.ocajp.i.v7.2.992 :

Post by JavaLegend »

This question is incorrect.

Code: Select all

class SomeClass{
    public static void main( String args[ ] ){
       if (args.length == 0 ){
          System.out.println("no arguments") ;
       }
       else{
          System.out.println( args.length + " arguments") ;
       }
    }
 }
The correct answer is: The program will fail to compile.

Reason: "args.length" is the improper use of the String method length().
The correct use of length() is args.length().

Can someone from enthuware confirm this. I just purchased you software and this is concerning to me.

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

Re: About Question enthuware.ocajp.i.v7.2.992 :

Post by admin »

The question is correct. args is an array.
Please try it out.

Also, I will suggest you to go through a book before attempting the mock exams because you have asked a very fundamental question.
-Paul.
If you like our products and services, please help us by posting your review here.

Post Reply

Who is online

Users browsing this forum: No registered users and 111 guests