ICSE
2023-24 Paper
COMPUTER APPLICATION SOLUTION
-----------------------------------------------------------------------------------------------------------
Maximum Marks:100
Time Allowed : Two Hours
Answer s to this paper must be written on the provided separately.
You will not allowed to write during the first 15 minutes.
This time is to be spent in reading the question paper.
The time given at the head on this Paper is the time allowed for writing the answers.
----------------------------------------------------------------------------------------------------------------
This Paper is divided into two Sections.
Attempt all questions from Section A and any four questions from Section B.
The intended marks for questions or parts of questions are given in brackets[].
------------------------------------------------------------------------------------------------------------------
SECTION - A
Question 1.
Consider the above picture and choose the correct statement from the following
(i) Consider the above picture and choose the correct statement from the following:

Question 2.
(i) Write Java expression for:
(i) Evaluate the
expression when x is 4:
x+=x++ * ++x%2;
Solution: x+=x++ * ++x%2;
which is x= x + x++ * ++x%2
Here x=4
x= 4 + 4 x 5%2;
x= 4 + 4 x 1
Ans: x=8;
(iii) Rewrite the following do while program segment using for:
x=20; y=20;
do
{
x++;
y++;
}while(x<=20);
System.out.println(x*y);
(ii) Evaluate the expression when x is 4 :
x+=x++ * ++x +x%2;
= 4 + 4*6%2
= 4 + 0
= 4
(iii) for(x=10, y=20;x<=20;x++,y++)
(iv) infinite loop , No Output
(v) x=100
(vi) (a) Order of the array.
4 3 2
(0, 0) (0, 1) (0 ,2)
7 8 2
(1, 0) (1, 1) (1 ,2)
8 3 10
(2, 0) (2, 1) (2 ,2)
1 2 9
(3, 0) (3, 1) (3 ,2)
So solution is x[0][0] + x[2][2] =14+10=24
(vii) Boxing and Unboxing
Boxing is the process of converting a primitive datatype into an object wrapper datatype, and
unboxing is the process of converting a value from an object wrapper type back to the native
primitive value. Further on, we can say that both boxing and unboxing operations are a
subset of typecasting.
(viii) String a="KING", b="KINGDOM";
System.out.println(a.compareTo(b)); Answer is false
(ix) Here the concept is Constructor overloading
First Constructor is default Constructor
Second is Parameterized Constructor.
(x) (a) java.lang
(b) import java.util.* ; statement is required to access Scanner Class
SECTION B
Question 3:
Solution:-
import java.util.*;
public class courier
{
String name;
double weight;
String address;
double bill;
char type;
public void accept()
{
Scanner sc=new Scanner(System.in);
System.out.println(“Enter Name of Customer:”);
name=sc.nextLine();
System.out.println(“Enter Weight of Parcel in kilogram:”);
weight=sc.nextDouble()
System.out.println(“Enter Address of Recipient:”);
Address=sc.nextLine()
System.out.println(“Enter Type D-Domestic I-International :”);
type=(char) sc.next().charAt(0);
}
public void calculate()
{
if(weight<=5)
{
bill=weight*8.00;
}
else if(weight<=10)
{
bill=5*8+(weight-5)*7.00;
}
else if(weight>10)
{
bill=5*8.00+5*7.00+(weight-5)*5.00;;
}
public void print()
{
if(type==’D’)
{
System.out.println(“Bill : “+bill);
}
if(type==’I’)
{
Bill=bill+1500;
System.out.println(“Bill : “+bill);
}
}
Question 4:
Solution:-
public class perform
{
public perform(double r, double h)
{
double l=Math.sqrt(r*r+h*h);
double CSA= pi*r*l;
System.out.println (”Curved Surface Area :”+CSA);
}
public perform(int r, int c)
{
for(int i=1;i<=r;i++)
{
for(int j=1;j<=c;j++)
{
System.out.print(c+ “ “);
}
System.out.println();
}
public perform(int m, int n,char ch)
{
if(ch==’R’)
System.out.println (m%n);
if(ch==’Q’)
System.out.println (m/n);
}
}
}
Question 5:
Solution:-
Import java.util.*;
public class EvenPal
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
int no=0,sum=0,rev=0;
System.out.println (“Enter Number”);
no=sc.nextInt();
int actno=no;
while(n>0)
{
int p=no%10;
rev=rev*10+p;
no=no/10;
}
sum=0;
if(rev==actno)
{
while (rev>0)
{
int p=rev%10;
sum=sum+p;
rev=rev/10;
}
}
if(sum%2==0)
{
System.out.println(“EvenPal Number”);
}
else
{
System.out.println(“Not an EvenPal Number”);
}
}
}
Question 6:
Solution:-
import java.util.Scanner;
public class DiagonalMatrix
{
private static boolean checkDiagonalMatrix(int[][] matrix){
for(int i=0; i<matrix.length;i++)
for(int j=0; j<matrix[i].length;j++){
if((i == j && matrix[i][j] == 0) || (i != j && matrix[i][j] != 0)) return false;
}
return true;
}
}
}
Question 7:
Solution:-
public class SelectionSort{
public static void main(String args[])
{
int arr[]={110061, 110001, 110029, 110023, 110055, 110006, 110019, 110033};
for (int i = 0; i < arr.length - 1; i++)
{
int index = i;
for (int j = i + 1; j < arr.length; j++){
if (arr[j] < arr[index]){
index = j;//searching for lowest index
}
}
int smallerNumber = arr[index];
arr[index] = arr[i];
arr[i] = smallerNumber;
}
System.out.println("Sorted Values are...n");
for (int i = 0; i < arr.length - 1; i++)
{
System.out.print(arr[i]+",");
}
}
Question 8:
Solution:-
import java.util.*;
public class ValidMail
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String mail=new String(“”);
System.out.println(“Enter an Email Address: “);
mail=sc.nextLine();
if(mail.indexOf(“@”)>=0)
{
System.out.println(“Yes it is a Valid Email!”);
}
if(mail.indexOf(“.”)>=0)
{
System.out.println(“Yes it is a Valid Email!”);
}
if(mail.compareOf(“gmail”)>=0)
{
System.out.println(“Yes it is a Valid Email!”);
}
}
}
}}
No comments:
Post a Comment