Declaration and access control in JAVA online Test

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

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];

System.out.println(i[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?


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();

ad.amethod();

}

public void amethod(){

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

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

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

System.out.print(ia3.length);

}

}






























Description:

Questions span array declarations in JAVA.

Comments
Suriya Akter
By: Suriya Akter
792 days 1 hours 30 minutes ago

Good questions!!

Want to learn?

Sign up and browse through relevant courses.

or fill this simple form
Name:
Your Email:
Password:
Country:
Contact no.:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as shown in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
Biswadip Goswami
Knowledge is for ALL !
User
2 Members Recommend
56 Followers

Your Facebook Friends on WizIQ

Connect