Declaration and access control in JAVA Online Test

How to resize an array in a single statement while keeping the original contents?

To find out the last element of an array, the code written is:

public class MyAr{

public static void main(String argv[]){

int[] i = new int[5];




What happens when compiled?

If you want to traverse through the elements of an array and stop when you reach the last element, knowing that arrays contain information about their size, which one of the following are you going to use?

If an array is defined as static char a[10]; then the elements of a will be set to
an undetermined value
blank character
character ‘~0’

To create a game of TIC-TAC-TOE, you need to declare a multi - D array.

Which of the given belowoption will do the work for you?

Which is a better way to populate your array without using a FOR statement?

What will happen when you compile and execute the following piece of code?

public class Ardec{

public static void main(String argv[]){

Ardec ad = new Ardec();



public void amethod(){

int ia1[]= {1,2,3};

int[] ia2 = {1,2,3};

int ia3[] = new int[] {1,2,3};





Questions span array declarations in JAVA.


Suriya Akter

Good questions!!

3840 days 21 minutes ago

Biswadip Goswami
Knowledge is Power !
2 Members Recommend

Your Facebook Friends on WizIQ