Question 2) What will happen if you try to compile and run the following code
public class MyClass { public static void main(String arguments[]) { amethod(arguments). } public void amethod(String[] arguments) { System.out.println(arguments). System.out.println(arguments[1]). } } 1) error Can’t make static reference to void amethod. 2) error method main not correct 3) error array must include parameter 4) amethod must be declared with String
Question 8) What will happen when you compile and run the following code?
public class MyClass{ static int i. public static void main(String argv[]){ System.out.println(i). } } 1) Error Variable i may not have been initialized 2) null 3) 1 4) 0
Question 9) What will happen if you try to compile and run the following code?
public class Q { public static void main(String argv[]){ int anar[]=new int[]{1,2,3}. System.out.println(anar[1]). } } 1) 1 2) Error anar is referenced before it is initialized 3) 2 4) Error: size of array must be defined
What will happen if you try to compile and run the following code?
public class Q { public static void main(String argv[]){ int anar[]=new int[5]. System.out.println(anar[0]). } } 1) Error: anar is referenced before it is initialized 2) null 3) 0 4) 5
What will be the result of attempting to compile and run the following code?
abstract class MineBase { abstract void amethod(). static int i. } public class Mine extends MineBase { public static void main(String argv[]){ int[] ar=new int[5]. for(i=0.i <. ar.length.i ) System.out.println(ar[i]). } } 1) a sequence of 5 0’s will be printed 2) Error: ar is used before it is initialized 3) Error Mine must be declared abstract 4) IndexOutOfBoundes Error