Objective type Question Answer
Objective type Question Answer
Class – X , ICSE
Prepared & Guided By : Souvik Chakraborty , M.Sc(C.S) , B.Ed
1. Basics
Q1.
Answer:
Q2.
Answer:
A is false, R is true.
(Explanation: Java does not support multiple inheritance with classes
directly, but it can be achieved through interfaces.)
Q3.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 1/17
A is true, R is false.
(Explanation: The System.gc() method only suggests the JVM to run the
garbage collector; it does not guarantee it.)
Q4.
Answer:
Q5.
Answer:
2. Loops
Q1.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 2/17
Q2.
Assertion (A): The for loop is useful for iterating over an array.
Reason (R): The for loop can have an initialization, condition, and
increment/decrement in a single line.
Answer:
Q3.
Answer:
Q4.
Assertion (A): The continue statement in a loop skips the current iteration.
Reason (R): The continue statement transfers control to the beginning of the loop.
Answer:
Q5.
Assertion (A): A do-while loop checks the condition at the start of the loop.
Reason (R): A do-while loop is suitable for executing the body at least once
regardless of the condition.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 3/17
A is false, R is true.
(Explanation: The condition in a do-while loop is checked after the loop
body runs.)
3. Arrays
Q1.
Answer:
Q2.
Assertion (A): The length of an array can be changed after its declaration.
Reason (R): Arrays in Java are fixed in size once created.
Answer:
A is false, R is true.
(Explanation: Arrays in Java have a fixed size, and their length cannot be
modified after declaration.)
Q3.
Answer:
Assertion (A): Arrays can store both primitive types and objects in Java.
Reason (R): Arrays are a part of Java’s collection framework.
Answer:
A is true, R is false.
(Explanation: Arrays are not a part of the Java collection framework; they
are part of the core language.)
Q5.
Answer:
4. Strings
Q1.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 5/17
Q2.
Answer:
Q3.
Answer:
Q4.
Answer:
Q5.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 6/17
A is false, R is true.
(Explanation: Strings are not primitive; they are objects of the String
class.)
5. Methods
Q1.
Answer:
Q2.
Answer:
Q3.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 7/17
Q4.
Answer:
Q5.
Answer:
A is false, R is true.
(Explanation: Methods can return various data types, not just void.)
6. Constructors
Q1.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 8/17
Q2.
Answer:
Q3.
Answer:
Q4.
Answer:
A is false, R is false.
(Explanation: Constructors cannot be static.)
Q5.
7. Method Overloading
Q1.
Assertion (A): Method overloading allows multiple methods with the same name
in a class.
Reason (R): The methods must differ in their parameter type, number, or order.
Answer:
Q2.
Answer:
A is false, R is false.
(Explanation: Overloaded methods cannot be differentiated by return type
alone.)
Q3.
Answer:
By : Souvik_Chakraborty_M.Sc_CS 10/17
A is true, R is true, and R is the correct explanation of A.
Q4.
Assertion (A): Method overloading can only be done within the same class.
Reason (R): Method overriding is used to redefine methods in subclasses.
Answer:
Q5.
Answer:
1. Arrays
Q1.
class ArrayExample {
public static void main(String[] args) {
int[] arr = {10, 20, 30, 40, 50};
int i = 1, j = 3, sum = 0;
Output:
Sum: 145
Explanation:
Q2.
class ArrayManipulation {
public static void main(String[] args) {
int[] a = {5, 10, 15, 20, 25};
int x = 0, y = 4, diff = 0;
Output:
Difference: 15
Explanation:
By : Souvik_Chakraborty_M.Sc_CS 12/17
2. a[x++] + a[--y]: a[1] = 10 (post-increment), --y = 2, so a[2] = 15.
Difference becomes 15 + 10 + 15 = 40.
o Now x = 2, y = 2.
3. a[y--] - a[--x]: a[2] = 15, --x = 1, so a[1] = 10. Difference becomes
40 - (15 - 10) = 15.
Q3.
class ArrayRotation {
public static void main(String[] args) {
int[] arr = {1, 2, 3, 4, 5};
int n = arr.length;
Output:
Copy code
2 3 4 5 1
3 4 5 1 2
4 5 1 2 3
5 1 2 3 4
1 2 3 4 5
Explanation: The program performs a left rotation on the array for n iterations.
Each iteration moves the first element to the end while shifting all others to the
left.
By : Souvik_Chakraborty_M.Sc_CS 13/17
Q4.
class ArraySum {
public static void main(String[] args) {
int[][] arr = {
{1, 2, 3},
{4, 5, 6},
{7, 8, 9}
};
Output:
Diagonal 1 Sum: 15
Diagonal 2 Sum: 15
Explanation:
Diagonal 1: 1 + 5 + 9 = 15
Diagonal 2: 3 + 5 + 7 = 15.
2. Strings
Q1.
class StringExample {
public static void main(String[] args) {
String s = "ICSE";
s = s.concat(" 2024").toLowerCase();
s = s.substring(0, 6);
System.out.println(s);
By : Souvik_Chakraborty_M.Sc_CS 14/17
}
}
Output:
420 202
Explanation:
Q2.
class PalindromeCheck {
public static void main(String[] args) {
String str = "MADAM";
String rev = "";
if (str.equals(rev)) {
System.out.println("Palindrome");
} else {
System.out.println("Not a Palindrome");
}
}
}
Output:
Palindrome
Q3.
class SubstringCount {
public static void main(String[] args) {
String s = "ICSE ICSE ICSE";
By : Souvik_Chakraborty_M.Sc_CS 15/17
String word = "ICSE";
int count = 0;
Output:
Count: 3
Explanation: The program iterates over the string and counts non-overlapping
occurrences of "ICSE".
Q4.
class ReplaceVowels {
public static void main(String[] args) {
String s = "ICSE 2024";
String result = "";
System.out.println(result);
}
}
Output:
*CS* 2024
Explanation:
The vowels (I, E) are replaced with *.
By : Souvik_Chakraborty_M.Sc_CS 16/17
Q5.
class AnagramCheck {
public static void main(String[] args) {
String str1 = "listen";
String str2 = "silent";
java.util.Arrays.sort(arr1);
java.util.Arrays.sort(arr2);
if (java.util.Arrays.equals(arr1, arr2)) {
System.out.println("Anagrams");
} else {
System.out.println("Not Anagrams");
}
}
}
Output:
Anagrams
Explanation:
Sorting the characters of both strings and comparing them shows that they are
anagrams.
By : Souvik_Chakraborty_M.Sc_CS 17/17