
Q91
Q91 Analyze this pseudocode:
SET num = 0 WHILE num <= 5 IF num MOD 2 = 0 THEN PRINT num END IF INCREMENT num
0 2 4
0 1 2 3 4 5
2 4
0 2 4 6
Q92
Q92 Spot the mistake:
int counter = 0;
while(counter < 5){
counter++;
}
System.out.println("Count: " + counter);
Loop never terminates
Counter not incremented
No error
Print statement incorrect
Q93
Q93 Which class is commonly used for simple keyboard input in Java?
Scanner
InputStream
BufferedReader
FileReader
Q94
Q94 What does 'BufferedReader' in Java provide that 'Scanner' does not?
Faster input reading
Input from file only
Different data types
Graphical interface
Q95
Q95 How do you access the third element in an array named 'arr'?
arr[2]
arr[3]
arr(2)
arr(3)
Q96
Q96 What will happen if you try to access an index outside the bounds of an array in Java?
Compile-time error
Runtime error: ArrayIndexOutOfBoundsException
No error
Logical error
Q97
Q97 What is the purpose of the 'length' attribute in a Java array?
To determine the size of the array
To modify the size of the array
To sort the array
To initialize the array
Q98
Q98 In a multi-dimensional array, how do you access the element in the second row and third column of an array named 'matrix'?
matrix[1][2]
matrix[2][3]
matrix[2][2]
matrix[1][3]
Q99
Q99 What does this Java code do?
int[][] arr = {{1, 2}, {3, 4}};
for(int i = 0;
i < arr.length;
i++) {
for(int j = 0;
j < arr[i].length;
j++) {
System.out.print(arr[i][j] + " "); } System.out.println();
}
Prints a 2D array in matrix form
Prints only the first row of the array
Prints the sum of the array elements
Gives an error
Q100
Q100 Analyze this code:
int[] nums = new int[3];
nums[1] = 10;
int x = nums[1] + nums[0];
System.out.println(x);
0
10
Error
None
Q101
Q101 Determine the output of this pseudocode:
SET arr = [10, 20, 30]
SET sum = 0
FOR i = 0 TO LENGTH(arr) - 1
INCREMENT sum BY arr[i]
PRINT sum
60
10 20 30
Error
None
Q102
Q102 Spot the mistake in this code:
String[] names = {"Java", "Python", "C"};
for(int i = 0;
i < names.length;
i++) {
System.out.println(names[i].length());
}
Prints incorrect lengths
No error
Syntax error
Logic error
Q103
Q103 What is the primary feature of Object-Oriented Programming in Java?
Inheritance
Abstraction
Encapsulation
Polymorphism
Q104
Q104 What does 'inheritance' in Java imply?
A class can call methods of another class
A class shares structure and behaviors from another class
A class must override all methods of another class
A class is a blueprint for objects
Q105
Q105 Which keyword is used for inheritance in Java?
extends
implements
inherits
super
Q106
Q106 Which access modifier in Java makes a member accessible only within its own class?
private
public
protected
default
Q107
Q107 Analyze the output of this code snippet:
class Car {
String model; Car(String model) { this.model = model;
}
} public class Main {
public static void main(String[] args) { Car myCar = new Car("Tesla"); System.out.println(myCar.model); } }
Tesla
null
Error
Model
Q108
Q108 What does this Java code do?
class Animal {
void sound() {
System.out.println("Generic Sound");
}
} class Dog extends Animal { void sound() { System.out.println("Bark"); } } public class Main { public static void main(String[] args) { Animal myAnimal = new Dog(); myAnimal.sound(); } }
Prints "Generic Sound"
Prints "Bark"
Error
Does nothing
Q109
Q109 What will this pseudocode output?
CLASS Vehicle SET wheels = 4 METHOD showWheels PRINT wheels END CLASS Main CREATE Vehicle v CALL v.showWheels
4
0
Error
None
Q110
Q110 Spot the mistake:
class Calculator {
static void sum(int a, int b) {
System.out.println(a + b);
}
public static void main(String[] args) {
sum(10, 20); }
}
No static context for sum
No error
sum method should return a value
Incorrect parameters
Q111
Q111 What is an abstract class in Java?
A class that cannot be instantiated and has at least one abstract method
A class with only static methods
A final class
A class that cannot be extended
Q112
Q112 What happens when a class implements an interface in Java?
It must provide implementation for all methods in the interface
It becomes an abstract class
It can no longer extend other classes
It automatically inherits from java.lang.Object
Q113
Q113 What will this Java code output?
interface Printable {
void print();
}
class Test implements Printable { public void print() {
System.out.println("Hello");
} }
public class Main {
public static void main(String[] args) {
Test t = new Test();
t.print(); }
}
Hello
Error
Nothing
Printable
Q114
Q114 What is the primary purpose of a package in Java?
To provide network support
To optimize code performance
To group related classes and interfaces
To manage software versions
Q115
Q115 How do you access a class from a package in Java?
By using the 'package' keyword before the class name
By importing the class
By inheriting the class
By implementing an interface
Q116
Q116 What is the purpose of a try-catch block in Java?
To handle exceptions
To optimize code
To declare variables
To control program flow
Q117
Q117 Which keyword is used to manually throw an exception in Java?
throw
throws
try
catch
Q118
Q118 What will the following code output:
try {
int a = 5 / 0;
System.out.println(a);
}
catch (ArithmeticException e) {
System.out.println("Arithmetic Error");
}
Arithmetic Error
5
Error
None
Q119
Q119 What will this pseudocode output?
SET a = 10
SET b = 0
TRY
SET c = a / b
CATCH EXCEPTION PRINT "Error" END TRY
Error
10
0
None
Q120
Q120 What will be the result of this pseudocode?
SET arr = [1, 2, 3]
TRY
PRINT arr[3]
CATCH EXCEPTION
PRINT "Array Error" END TRY
1 2 3
Array Error
Error
None

