question 41)
given the following code what will be output?
public class pass{
static int j=20;
public static void main(string argv[]){
int i=10;
pass p = new pass();
p.amethod(i);
system.out.println(i);
system.out.println(j);
}
public void amethod(int x){
x=x*2;
j=j*2;
}
}
1) error: amethod parameter does not match variable
2) 20 and 40
3) 10 and 40
4) 10, and 20
question 42)
what code placed after the comment //for loop would result in the population of every element of the array ia[] with a value from variable i.?
public class lin{
public static void main(string argv[]){
lin l = new lin();
l.amethod();
}
public void amethod(){
int ia[] = new int[4];
//start for loop
{
ia[i]=i;
system.out.println(ia[i]);
}
}
}
1) for(int i=0; i < ia.length() -1; i++)
2) for (int i=0; i< ia.length(); i++)
3) for(int i=1; i < 4; i++)
4) for(int i=0; i< ia.length;i++) 2]