Debugging Questions in JAVA
Debugging Questions in JAVA
int x = 10;
System.out.println(x++); // Post-increment
A) 10
B) 11
C) Compilation error
D) Runtime error
int a = 10;
int b = 20;
A) 10
B) 20
C) `a`
Debugging Questions in JAVA
D) `b`
System.out.println(str.toUpperCase().substring(1, 4));
A) `HEL`
B) `HELLO`
C) `ELL`
D) `EL`
System.out.println(arr[5]);
A) 5
B) `ArrayIndexOutOfBoundsException`
C) `null`
Debugging Questions in JAVA
D) 4
int i = 0;
while (i < 5) {
i++;
System.out.println(i);
A) 4
B) 5
C) 6
D) 0
System.out.println(str);
}
Debugging Questions in JAVA
}
A) `Java`
B) `Java Programming`
C) `JavaProgramming`
D) Compilation error
int a = 10;
int b = 0;
try {
System.out.println(a / b);
} catch (ArithmeticException e) {
System.out.println("Error");
A) `Error`
B) `Infinity`
C) `10`
D) `0`
String s = "123";
System.out.println(num);
A) `123`
B) `12`
C) `null`
D) `Exception`
System.out.println(i);
A) `0 1 2 3`
B) `0 1 2`
C) `1 2 3`
Debugging Questions in JAVA
D) `0 1`
int a = 5;
int b = a++;
System.out.println(b);
A) `5`
B) `6`
C) `4`
D) `0`
String s = "hello";
s = s.replace('l', 'r');
System.out.println(s);
A) `herro`
Debugging Questions in JAVA
B) `herro`
C) `herro`
D) `hello`
arr[0] = "one";
arr[1] = "two";
System.out.println(arr[2]);
A) `null`
B) `two`
C) `one`
D) `ArrayIndexOutOfBoundsException`
System.out.println(str.substring(1, 4));
}
Debugging Questions in JAVA
}
A) `Java`
B) `ava`
C) `ja`
D) `a`
int i = 1;
System.out.println(i++ + ++i);
A) `4`
B) `5`
C) `6`
D) `7`
System.out.println("Hello" + 1 + 2);
}
Debugging Questions in JAVA
A) `Hello12`
B) `Hello3`
C) `Hello1 2`
D) `Hello`
System.out.println(str.charAt(2));
A) `J`
B) `a`
C) `v`
D) `a`
};
A) `1 2 3`
B) `1`
`2`
`3`
C) `3 2 1`
D) `2 3 1`
String s = "abc";
s = s.toUpperCase();
System.out.println(s);
A) `ABC`
B) `abc`
C) `Abc`
D) `null`
Debugging Questions in JAVA
19. What will be the result of the following code?
String s = "123a";
System.out.println(num);
A) `123`
B) `123a`
C) `Exception`
D) `null`
int a = 5;
int b = 10;
System.out.println(++a * b--);
A) `60`
B) `55`
Debugging Questions in JAVA
C) `50`
D) `45`
System.out.println(str.indexOf('l'));
A) `2`
B) `3`
C) `-1`
D) `4`
System.out.println(nums[nums.length]);
A) `3`
B) `IndexOutOfBoundsException`
Debugging Questions in JAVA
C) `2`
D) `null`
System.out.println(str.concat(" programming").toUpperCase());
A) `java programming`
B) `JAVA PROGRAMMING`
C) `Java programming`
D) `JAVA PROGRAMMING.`
int a = 7;
int b = 3;
System.out.println(a % b);
A) `2`
Debugging Questions in JAVA
B) `1`
C) `0`
D) `3`
String s = "hello";
System.out.println(s.equalsIgnoreCase("HELLO"));
A) `true`
B) `false`
C) `hello`
D) `HELLO`
System.out.println("Hello".charAt(0));
A) `H`
B) `e`
Debugging Questions in JAVA
C) `Hello`
D) `0`
str = str.toLowerCase();
System.out.println(str.substring(2));
A) `java`
B) `va`
C) `ava`
D) `jav`
arr[i] = arr[i] * 2;
System.out.println(Arrays.toString(arr));
Debugging Questions in JAVA
}
A) `[2, 4, 6]`
B) `[1, 2, 3]`
C) `[2, 4, 6]`
D) `[2, 4, 6]`
int x = 10;
A) `true`
B) `false`
C) `10`
D) `null`
System.out.println(2 + 3 * 4);
}
Debugging Questions in JAVA
}
A) `14`
B) `20`
C) `24`
D) `5`
int x = 5;
int y = 0;
try {
System.out.println(x / y);
} catch (ArithmeticException e) {
System.out.println(numbers[i]);
A) The code will print all numbers in the array and then throw an
ArrayIndexOutOfBoundsException.
B) The code will print all numbers in the array without error.
int a = 10;
int b = 20;
swap(a, b
}
Debugging Questions in JAVA
int temp = x;
x = y;
y = temp;
System.out.println(str.length());
35. Consider the following Java code. What will be the output?
System.out.println(str.substring(3, 10));
A) deb
B) ugging
C) bugging
D) debugg