OCA7
bhavneet kaur wrote:
i am not getting
during execution on command prompt
java classname ABC
it prints ABC
but java classname AB or java classname A
its not working
OCA7
bhavneet kaur wrote: dear still i am not getting can you explain in detail
OCA7
Enkita mody wrote:
When you do run i.e. java classname ABC then
a1[0] is A
a1[1] is B
a1[2] is C
.
Rameshwar Soni wrote:
Enkita mody wrote:
When you do run i.e. java classname ABC then
a1[0] is A
a1[1] is B
a1[2] is C
.
Incorrect. Here you are passing only one argument i.e. ABC therefore a1[0] is ABC and not what you said.
OCA7
bhavneet kaur wrote:class C {
public static void main (String[] a1) {
System.out.print(a1[0] + a1[1] +a1[2]);
}}
bhavneet kaur wrote: thank you so much
it means ,as a1 is a string then without space
example java classname ABC
it will be considered as one,so input from command line must be given with space,right.
i think in a website its given wrong they are giving input A B C
and showing output as BC and runtime Exception
OCA7
bhavneet kaur wrote:
class C1
{
static int s;
public static void main(String a[])
{
C1 obj=new C1();
obj.m1();
System.out.println(s);
}
void m1()
{
int x=1;
m2(x);
System.out.println(x+"");
}
void m2(int x)
{
x=x*2;
s=x;
}
}
//its output is :
1
2
why the value of x doesnt changed??
OCA7
Enkita mody wrote:
No,if you will run it with java classname ABC then it wont compile, it will give compile error.because there is only a1[0].
Rameshwar Soni wrote:
Enkita mody wrote:
No,if you will run it with java classname ABC then it wont compile, it will give compile error.because there is only a1[0].
You use your words properly. How come java classname ABC won't compile ? We are executing our program here rather than compiling.
OCA7