Page 1 of 1

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

Posted: Wed Apr 02, 2014 2:22 pm
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?
:?

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

Posted: Wed Apr 02, 2014 8:37 pm
by admin
No, it will print "no arguments" when run with zero argument and "1 arguments" when run with one argument.

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

Posted: Thu Apr 03, 2014 12:37 pm
by Nisim123
Thanks, it is probably the way the sentence is set (from the grammatical POV...) that confused me....
:oops:

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

Posted: Sun Dec 20, 2015 11:54 pm
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.

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

Posted: Mon Dec 21, 2015 3:38 am
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.