Question 1 of 25
Hints left: 3
Q1
What is the purpose of the trim() method of a String object in Java?
Q2
What will be the output of the following Java code? class array_output { public static void main(String args[]) { int array_variable [] = new int[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = i; System.out.print(array_variable[i] + " "); i++; } } }
Q3
What will be the output of the following Java code? class array_output { public static void main(String args[]) { int array_variable[][] = {{ 1, 2, 3}, { 4 , 5, 6}, { 7, 8, 9}}; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < 3 ; ++j) sum = sum + array_variable[i][j]; System.out.print(sum / 5); } }
Q4
Which of the following is true about Java strings?
Q5
Predict the output: public class Test{ public static void main(String... args){ int[] index = new int[5]; System.out.println(index instanceof Object); } }
Q6
Which method is used to find the index of the first occurrence of a specified character in a string in Java?
Q7
Which of these is an incorrect array declaration?
Q8
Which of the following methods is used to replace all occurrences of a specified character in a string in Java?
Q9
What is the correct way to create a new empty String object in Java?
Q10
In Java, which operator is used to concatenate two strings?
Q11
In Java, which class is used to represent a sequence of characters as a string?
Q12
Which of these is necessary to specify at time of array initialization?
Q13
What will be the output of the following Java code? class multidimention_array { public static void main(String args[]) { int arr[][] = new int[3][]; arr[0] = new int[1]; arr[1] = new int[2]; arr[2] = new int[3]; int sum = 0; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) arr[i][j] = j + 1; for (int i = 0; i < 3; ++i) for (int j = 0; j < i + 1; ++j) sum + = arr[i][j]; System.out.print(sum); } }
Q14
In Java, what is the result of the expression "Hello".substring(1, 4)?
Q15
What does the length() method of a String object in Java return?
Q16
What is the value of a[1] after the following code is executed? int[] a = {0, 2, 4, 1, 3}; for(int i = 0; i < a.length; i++) a[i] = a[(a[i] + 3) % a.length];
Q17
Which of these is an incorrect Statement?
Q18
What will be the output of the following Java code? class evaluate { public static void main(String args[]) { int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9}; int n = 6; n = arr[arr[n] / 2]; System.out.println(arr[n] / 2); } }
Q19
What will be the output of the following Java code? class array_output { public static void main(String args[]) { char array_variable [] = new char[10]; for (int i = 0; i < 10; ++i) { array_variable[i] = 'i'; System.out.print(array_variable[i] + ""); } } }
Q20
What is the correct way to check if a string starts with a specific prefix in Java?
Q21
What will be the output of the following Java code? int arr[] = new int [5]; System.out.print(arr);
Q22
How do you convert a string to lowercase in Java?
Q23
Which of these operators is used to allocate memory to array variable in Java?
Q24
Which of the following methods is used to compare two strings for equality in Java?
Q25
What is the purpose of the charAt() method of a String object in Java?