- What will be printed?
1 System.out.println("Eduinq".length()); View Answer
Correct answer: B — 6
- Which of the following is true about Strings in Java?
View Answer
Correct answer: A — Strings are immutable
- What will be printed?
1 String s = "Eduinq"; 2 System.out.println(s.toUpperCase()); View Answer
Correct answer: B — EDUINQ
- Which of the following is true about arrays in Java?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 int[] arr = {1,2,3}; 2 System.out.println(arr[1]); View Answer
Correct answer: B — 2
- Which of the following is true about exceptions in Java?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 try { 2 int x = 10/0; 3 } catch(Exception e) { 4 System.out.println("Eduinq Exception"); 5 } View Answer
Correct answer: A — Eduinq Exception
- Which of the following is true about wrapper classes?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 Integer i = Integer.valueOf("100"); 2 System.out.println(i + 50); View Answer
Correct answer: B — 150
- Which of the following is true about finally block?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 String s = "Eduinq"; 2 System.out.println(s.charAt(2)); View Answer
Correct answer: B — u
- Which of the following is true about StringBuilder?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 StringBuilder sb = new StringBuilder("Eduinq"); 2 sb.append(" Portal"); 3 System.out.println(sb); View Answer
Correct answer: B — Eduinq Portal
- Which of the following is true about StringBuffer?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 int[] arr = new int[3]; 2 System.out.println(arr[0]); View Answer
Correct answer: A — 0
- Which of the following is true about NullPointerException?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 try { 2 String s = null; 3 System.out.println(s.length()); 4 } catch(NullPointerException e) { 5 System.out.println("Eduinq NullPointer"); 6 } View Answer
Correct answer: A — Eduinq NullPointer
- Which of the following is true about autoboxing?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 Integer i = 10; 2 int j = i; 3 System.out.println(j); View Answer
Correct answer: A — 10
- Which of the following is true about ArrayIndexOutOfBoundsException?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 String s = "Eduinq Portal"; 2 System.out.println(s.indexOf("Portal")); View Answer
Correct answer: A — 7
- Which of the following is true about String.equals() vs ==?
View Answer
Correct answer: C — Both A and B
- What will be printed?
1 String s1 = new String("Eduinq"); 2 String s2 = new String("Eduinq"); 3 System.out.println(s1 == s2); View Answer
Correct answer: B — false
- Which of the following is true about arrays?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 int[] arr = {10,20,30}; 2 System.out.println(arr.length); View Answer
Correct answer: B — 3
- Which of the following is true about try-catch-finally?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 try { 2 int[] arr = new int[2]; 3 System.out.println(arr[5]); 4 } catch(ArrayIndexOutOfBoundsException e) { 5 System.out.println("Eduinq Array Exception"); 6 } View Answer
Correct answer: A — Eduinq Array Exception
- Which of the following is true about custom exceptions?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 try { 2 throw new Exception("Eduinq Custom Exception"); 3 } catch(Exception e) { 4 System.out.println(e.getMessage()); 5 } View Answer
Correct answer: A — Eduinq Custom Exception
- Which of the following is true about wrapper classes?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 Integer i = Integer.parseInt("200"); 2 System.out.println(i); View Answer
Correct answer: A — 200
- Which of the following is true about NumberFormatException?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 try { 2 Integer.parseInt("Eduinq"); 3 } catch(NumberFormatException e) { 4 System.out.println("Eduinq Number Exception"); 5 } View Answer
Correct answer: A — Eduinq Number Exception
- Which of the following is true about String.valueOf()?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 System.out.println(String.valueOf(123) + "Eduinq"); View Answer
Correct answer: A — 123Eduinq
- Which of the following is true about Arrays.toString()?
View Answer
Correct answer: A — Converts array to readable string
- What will be printed?
1 int[] arr = {1,2,3}; 2 System.out.println(java.util.Arrays.toString(arr)); View Answer
Correct answer: A — [1, 2, 3]
- Which of the following is true about String.split()?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 String s = "Eduinq,Portal"; 2 String[] parts = s.split(","); 3 System.out.println(parts[1]); View Answer
Correct answer: B — Portal
- Which of the following is true about String.trim()?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 String s = " Eduinq "; 2 System.out.println(s.trim()); View Answer
Correct answer: A — Eduinq
- Which of the following is true about String.compareTo()?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 System.out.println("Eduinq".compareTo("Portal")); View Answer
Correct answer: A — Negative number
- Which of the following is true about String.contains()?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 System.out.println("Eduinq Portal".contains("Portal")); View Answer
Correct answer: A — true
- Which of the following is true about String.isEmpty()?
View Answer
Correct answer: D — Both A and B
- What will be printed?
1 String s = ""; 2 System.out.println(s.isEmpty()); View Answer
Correct answer: A — true
- Which of the following is true about StringBuilder.reverse()?
View Answer
Correct answer: D — All of the above
- What will be printed?
1 StringBuilder sb = new StringBuilder("Eduinq"); 2 System.out.println(sb.reverse()); View Answer
Correct answer: A — qniudE
- Which of the following is true about exception hierarchy in Java?
View Answer
Correct answer: D — All of the above