Java - Arrays

page 1 out of 3

page 1 out of 3




Question 3     

Which of the following compiles without errors?






Question 4     

What is the output of the following code?

public class Main extends A{  
    public static void main(String args[]){  
        int arr[]=new int[100];
        System.out.println(arr.length);
   }  
}





Question 5     

What is the output of the following code?

public class Main extends A{  
    public static void main(String args[]){  
        int arr[]=new int[0];
        System.out.println(arr.length);
   }  
}





Question 6     

What is the output of the following code?

public class Main extends A{  
    public static void main(String args[]){  
        int arr[]=new int[100];
        System.out.println("arr[2] = "+arr[2]);
   }  
}






Question 7     

What is the output of the below code?

public class Main{  
    public static void main(String args[]){  
        int arr[]={100,200,300,400};
        for(int i: arr)
            System.out.print(i+"-");
   }  
}






Question 8     

What is the output of the following code?

public class Main{  
    public static void main(String args[]){  
        int arr[]={100,200,0300,400};
        for(int i: arr)
            System.out.print(i+"-");
   }  
}






Question 9     

What is the output of the following program?

public class Main{  
    public static void main(String args[]){  
        int arr[]=new int[10];
        System.out.println(arr.length);
        arr=new int[100];
        System.out.println(arr.length);
   }  
}






Question 10     

What is the output of the following code?

public class Main{  
    public static void main(String args[]){  
        int arr[]=new int[2];
        arr[0]=1;
        arr[2]=2;
        arr=new int[5];
        for(int i: arr)
            System.out.print(i+"-");
   }  
}




page 1 out of 3

page 1 out of 3


Sign Up Page

Oops!!

To view the solution need to Login



Score : 0 / 0
L
o
a
d
i
n
g
.
.
.