Question 1 of 25
Hints left: 3
Q1
What is the purpose of the System.arraycopy() method in Java?
Q2
What is the default initial value of numeric elements in an array of type int in Java?
Q3
How do you declare and initialize an array of integers with 5 elements in Java?
Q4
Which of the following statements is true about arrays in Java?
Q5
What is the correct way to initialize a two-dimensional array in Java?
Q6
What can directly access and change the value of the variable qusNo? package com.mypackage; public class Test{ private int qusNo = 100; }
Q7
What will be the output for the below code? static public class Test{ public static void main(String[] args){ char c = 'a'; switch(c){ case 65 : System.out.println("one");break; case 'a': System.out.println("two");break; case 3 : System.out.println("three"); } } }
Q8
Determine output: class A{ { System.out.print("b1 "); } public A(){ System.out.print("b2 "); } } class B extends A{ static{ System.out.print("r1 "); } public B(){ System.out.print("r2 "); } { System.out.print("r3 "); } static{ System.out.print("r4 "); } } public class Test extends B{ public static void main(String[] args){ System.out.print("pre "); new Test(); System.out.println("post "); } }
Q9
What will be the output for the below code? public class Test{ static{ int a = 5; } public static void main(String[] args){ System.out.println(a); } }
Q10
What does the length attribute of an array in Java represent?
Q11
Which of the following is true about the size of an ArrayList in Java?
Q12
What will be the output after compiling and running following program code? public class Test{ static int a; public static void main(String[] args){ System.out.println("one"); call(1); } static void call(int a){ this.a=10; System.out.println("two "+a); } }
Q13
Name the keyword that makes a variable belong to a class, rather than being defined for each instance of the class.
Q14
What is the default initial value of elements in an array of type boolean in Java?
Q15
How do you access an element in a one-dimensional array named myArray at index 3 in Java?
Q16
Which of the following is a valid declaration and initialization of a String array in Java?
Q17
What is the highest index of an array with 10 elements in Java?
Q18
How do you declare a one-dimensional array in Java?
Q19
What happens if you try to access an array element at an index that is out of bounds in Java?
Q20
What will be the output after the following program is compiled and executed? public class Test{ public static void main(String args[]){ int x = 10; x = myMethod(x--); System.out.print(x); } static int myMethod(final int x){ return x--; } }
Q21
How do you declare a dynamic array (ArrayList) of integers in Java?
Q22
How do you find the number of rows in a two-dimensional array named matrix in Java?
Q23
What is the correct way to copy the elements of one array to another in Java?
Q24
In Java, arrays are objects of which class?
Q25
Which method is used to find the length of an array in Java?