Is there any possible way to run a java file with no argument and 1(as an argument) at the same time?The program will print no arguments and 1 arguments when called with zero and one arguments.
About Question enthuware.ocajp.i.v7.2.992 :
Moderator: admin
-
Nisim123
- Posts: 42
- Joined: Mon Jan 20, 2014 2:26 pm
- Contact:
About Question enthuware.ocajp.i.v7.2.992 :
It says that the right answer is:

-
admin
- Site Admin
- Posts: 10442
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.992 :
No, it will print "no arguments" when run with zero argument and "1 arguments" when run with one argument.
-
Nisim123
- Posts: 42
- Joined: Mon Jan 20, 2014 2:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.992 :
Thanks, it is probably the way the sentence is set (from the grammatical POV...) that confused me....

-
JavaLegend
- Posts: 1
- Joined: Sun Dec 20, 2015 11:46 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.992 :
This question is incorrect.
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.
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") ;
}
}
}
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: 10442
- Joined: Fri Sep 10, 2010 9:26 pm
- Contact:
Re: About Question enthuware.ocajp.i.v7.2.992 :
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.
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.
Who is online
Users browsing this forum: No registered users and 15 guests