Icse 2023 Paper With Solutions
Icse 2023 Paper With Solutions
Answer
import
Reason — import keyword is used to import built-in and user-defined packages into
our Java program.
Question 1(v)
Answer
4.0
Reason — Math.ceil method returns the smallest double value that is greater than
or equal to the argument and Math.sqrt method returns the square root of its
argument as a double value. Thus the given expression is evaluated as follows:
Math.sqrt(Math.ceil (15.3))
= Math.sqrt(16.0)
= 4.0
Question 1(vi)
Answer
break
Reason — The absence of break statement leads to fall through situation in switch
case statement.
Question 1(vii)
Answer
infinite
Reason — The given loop is an example of infinite loop as for each consecutive
iteration of for loop, the value of i will be updates as follows:
1 5 Initial value of i = 5
2 3 i=5-2=3
3 1 i=3-2=1
4 -1 i = 1 - 2 = -1
5 -3 i = -1 - 2 = -3 and so on...
Question 4
import java.util.Scanner;
public class KboatCharBubbleSort
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
char ch[] = new char[10];
System.out.println("Enter 10 characters:");
for (int i = 0; i < ch.length; i++) {
ch[i] = in.nextLine().charAt(0);
}
System.out.println("Original Array");
for (int i = 0; i < ch.length; i++) {
System.out.print(ch[i] + " ");
}
//Bubble Sort
for (int i = 0; i < ch.length - 1; i++) {
for (int j = 0; j < ch.length - 1 - i; j++) {
if (ch[j] > (ch[j + 1])) {
char t = ch[j];
ch[j] = ch[j + 1];
ch[j + 1] = t;
}
}
}
System.out.println("\nSorted Array");
for (int i = 0; i < ch.length; i++) {
System.out.print(ch[i] + " ");
}
}
}
Output
Question 5
import java.util.Scanner;
if(evenSum == oddSum)
System.out.println("Lead number");
else
System.out.println("Not a lead number");
}
System.out.println("Pattern: ");
obj.print();
Question 6
import java.util.Scanner;
int ac = 0;
int sc = 0;
int dc = 0;
char ch;
}
}
Output
Question 7
import java.util.Scanner;
if (i == l)
{
System.out.println("Not found");
}
else
{
System.out.println(n + " found at index " + i);
}
}
}
Output
Question 8
import java.util.Scanner;
public class KboatDigitSum
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
int oneSum = 0, twoSum = 0, d = 0;
int arr[] = new int[10];
System.out.println("Enter 10 numbers");
int l = arr.length;
}
}
Output