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
-
- 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:
-
- Site Admin
- Posts: 10058
- 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.
If you like our products and services, please help us by posting your review here.
-
- 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....
-
- 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.
-
- Site Admin
- Posts: 10058
- 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.
If you like our products and services, please help us by posting your review here.
Who is online
Users browsing this forum: No registered users and 111 guests