Discussion :: Java.lang Class - General Questions (Q.No.4)
|Nijin said: (Feb 25, 2011)|
|Can anybody help me understanding this?|
|Sathish said: (Jun 1, 2011)|
|I can't understanding this concept please any one help me.|
|Abhijit said: (Jun 17, 2011)|
|args=1,args=3,args=2,args=3 and hence rip=args=3|
|Akash Gupta said: (Aug 27, 2011)|
|This is very cconfusinig,i can't satisfied with your sugesition.|
|Sreekanth said: (Aug 30, 2011)|
|Actually if you check here as explained by args = java args = Myfile args = 1 and args = 3.
So the answer is not a correct one.
|Sundar said: (Sep 22, 2011)|
|The given answer is correct. I have tested the same.
Hope this will help you. Have a nice day!
|Asoka said: (Jan 10, 2012)|
|I think [B] is correct answer!
The same with Sundar!
|Arindam said: (Feb 1, 2012)|
|When we want to run a java program then we always use
But you use something more then that are stored in args array, which is also known as command line argument....
For ex- i write "java main_class_name Arindam Ghosh"
then program will run but 'Arindam' will stored in args and 'Ghosh' will stored in args;
That's why here rip=args=2
|Subhan said: (Aug 17, 2012)|
|Anybody can explain this code clearly please I can't understand|
|Anvesh said: (Nov 21, 2012)|
|Yes dude,actually this is command line args, so normally arrays will be starting with zero, so given that answer c is correct, how means
So this args value will be coming with we are using command line args. First you learn command line args carefully.
|Aanand said: (Jun 26, 2013)|
|Answer C is right.
Please do not get confused with args = java and args = Myfile . This is true in C but not in java. In java , command line arguments till application name (here Myfile) is not the part of array args.
|Gaurav Singh said: (Aug 24, 2013)|
|public class Test
public static void main (String args)
String biz = args;
String baz = args;
String rip = args;
System.out.println("Arg is " + rip);
the o/p needed is--> Arg is 2.
i.e. 2 is at the rip place.
And rip is args i.e 4th place.
Because cmd line arg start with 0,1,2,3,4 and so on.
Hence in the option we need 2 at the 4th place.
That's why the ans is 1 3 2 2.
|Santhosh said: (Sep 11, 2013)|
|What about option 4 ?|
|Narendra Prajapati said: (Apr 15, 2014)|
|At cmd line args array has contain index. Which is start from 0 to no of arg. So if we are giving 11 2 3 56(including space).
So args array will take 11 on 0th index and 2 will take on 1st and 3 will take on 2nd and 56 on 3rd.
|Sindoori said: (Apr 27, 2014)|
|If command line args starts from 0123 then how args is 3 and args is 2. The answer should be 1232.|
|Raju said: (Jun 4, 2014)|
|Guys Here question is asked about rip means args. So don't think about args, args or args. Only think that in 4th args i.e. args comes on which order.
String args position
biz = args 0
baz = args 1
rip = args 2
And we can easily say that,
Whatever we will give the sequence no in input the 4th place should be 2nd position and here is only in option.
1 3 2 2
|Ted said: (Jul 23, 2014)|
|The answer is right. It is all about the COMMAND LINE ARGUMENTS.
The Java application = Myfile so,
When you write a command-line arguments.
Java Myfile .....
In this case we want the output to be: Args is 2.
Java Myfile 1322.
args is 1.
args is 3 which is biz.
args is 2 which is baz.
args is 2 and since rip is args, the answer is C.
|Saurabh Omer said: (Sep 27, 2014)|
|Command line arguments accept max index definition.....
Then user must takes 4 values like java Myfile 1 2 3 4...
Then user must takes 3 values like java Myfile 2 3 4...
|Punam said: (Dec 16, 2014)|
|Not getting output.|
|Suneel said: (Jul 5, 2015)|
|Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 1.
|Sunil said: (Mar 7, 2016)|
|Completely not getting output. Please someone explain it in detail.|
|Abhishek said: (Oct 25, 2016)|
|Why D is not correct?
It also gives output as Arg is 2.
|Dave said: (Dec 18, 2016)|
|It was really true when we see that program executes that the fourth location must be 2.|
|Rakesh Kumar said: (Jan 23, 2017)|
This will generate ArrayIndexOutOfBoundException.
|Palak said: (Jul 16, 2017)|
Your explanation is very helpful to understand.
|Jay said: (Jul 7, 2018)|
$java -Xmx128M -Xms16M Example
same results 2 time(s).
Here is a result for above question.
|Vijaya said: (Dec 13, 2018)|
|I Am not understanding please explain correctly.|
|Harish said: (Feb 4, 2019)|
|'java Myfile' is written to run the program after compilation and it's not an argument. Actually arguments start from 1.
So, option C is the correct answer.
|Anil said: (Sep 23, 2019)|
|I can't understand this. Please, anyone, help me to get this.|
|Osama said: (May 6, 2020)|
Here args take the value from the command line i.e command line arguments from the keyboard.
When you compile the program and runs it using java Test .
Along with java Test you have to give the value for an array also like a,a,a for a give the int value 2 i.e you're passing the value from keyboard to that method here args is a parameter that expects some value from the user so, java Test 1,3,2,2 will be sent from the user keyboard and store it in an array in args so the value of
a=2 remember that a is already been specified.
Post your comments here:
Email : (optional)
» Your comments will be displayed only after manual approval.