1.What is the index of the first element in a Java array?
2. Which of the following is used to declare an array in Java?
3. What will be the output?
int[] arr = {1, 2, 3};
System.out.println(arr.length);
4. Which method is used to compare two strings in Java?
5. What is the output?
String s = "Java";
System.out.println(s.charAt(2));
6. Strings in Java are:
7. Which class is used to create a dynamic array in Java?
8. Which method adds an element to an ArrayList?
9. What is the default size of an ArrayList?
10. Which collection does NOT allow duplicate elements?
11. Which method is used to get a value from a HashMap?
12. What will happen if you add duplicate keys in a HashMap?
13. Which of the following allows key-value pairs?
14. What is the output?
String s1 = "Hello";
String s2 = "Hello";
System.out.println(s1 == s2);
15. Which method returns the size of a collection?
0 Comments