7 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]); } }
-
- a sequence of 5 0's will be printed
-
- Error: ar is used before it is initialized
-
- Error Mine must be declared abstract
-
- IndexOutOfBoundes Error
C
Correct answer
Explanation
Class Mine extends abstract class MineBase but doesn't implement the abstract method amethod(). Therefore Mine must also be declared abstract. Concrete subclasses must implement all inherited abstract methods. The array initialization code is correct (Java arrays default to zero values), but the class declaration is the issue.