ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

Max Marks: 80
[2 Hours]

General Instructions

  • Answers to this Paper must be written on the paper provided separately.
  • You will not be 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 of this Paper is the time allowed for writing the answers. O 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 [40 Marks]
Attempt All Question

Question 1.
(a) What is encapsulation? How does Java achieve encapsulation?
Answer:
Encapsulation is the wrapping of the data and its associated functions into a single unit. Java achieve encapsulation by enclosing the data and methods in the class.

(b) True or False:
(i) The default case is compulsory in the switch case statement
(ii) The default initial value of a boolean variable data type is false.
Answer:
(i) False
(ii) false

(c) Define the term byte code.
Answer:
High level program is compiled by java compiler to put in language called bytecode. This is understood by JVM in executing it.

(d) What is the result code stored in x, after evaluating the following expression:
intx = 5;
x+ =++*2+3*-x;
Answer:
30

(e) What is function prototype? Write a function prototype of:
A function poschar which takes a string argument and a character argument and returns an integer value.
Answer:
Function prototype is the declaration of function with its return type and number of arguments and data type of arguments.
int PosChar(String str, char ch);

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

Question 2.
(a) Show how the sequence {10, 5, 8, 12, 45, 1, 9, 11, 2, 23} changes step by step during the first two passes while arranging in ascending order using the bubble sort technique.
Answer:
10,5,8,12,45,1,9,11,2,23
5.10.8.12.45.1.9.11.2.23
5.8.10.12.45.1.9.11.2.23

(b) How will you import a scanner package? What is the default delimiter of an instance of the scanner class?
Answer:
import java.util.*; Default delimiter for scanner class is white space or tab or newline.

(c) Differentiate between Character. isUpperCase( ) and Character, to UpperCase()
Answer:
Character.IsUpperCaseO checks the uppercase character and returns boolean value.
Character.toUpperCaseO converts lower case character to upper case character and returns upper case character.

(d) Write a Java expression:! = 2π√L/g
Answer:
doube T = 2*3.14 * Math.sqrt(l/g);

(e) What is fall through? Give example.
Answer:
Fall through is a way in which all the cases of switch statement will be executed one by one if break is not encountered.
E.g. After case B is executed it executes case C to F.
switch(grade)
{
case ‘A’:
System.out.printlnC’Excellent!”);
break;
case ‘B’:
case ‘C’:
System.out.printlnC’Well done”); case ‘D’ :
System.out.println(“You passed”); case ‘F’:
System.out.println(“Better try again”);
break;
default:
System.out.println(“lnvalid grade”);
}

Question 3.
Write the output of the following print statement:
(a) System.out.print (“IXIXI”,replace(‘X ‘/CJ.indexOfCO.indexOfCC’^));
Answer:
3

(b) System.out.print(“robotics”.substring(!3).concat(“subject”.substring(3)));
Answer:
object

(c) System.out.printC’FUN WORLD”.startsWith(“FUN”)== (“COMPUTER IS FUN”.endsWith(“FUN”)));
Answer:
true

(d) System.out.print(Math.sqrt(Math.abs(Math.ceil(-25.25))));
Answer:
5.0

(e) System.out.print(Math.max(Math.pow(Math.round(6.25),2),(Math. pow(Math.rint(1.8),3))));
Answer:
36

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

Question 4.
Write the output of the following segment of code:
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 1
Answer:
(a) 65
66
89
90

(b) 100

(c) 12
15
20
27
36

(d) 1615
1817
2019
2221
2423

(e) Hello
Hello

SECTION – B (60 Marks)
Attempt any four questions from this Section

The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted.

Flow-Charts and Algorithms are not required.

Question 5.
Given below is hypothetical table showing rates of Income Tax for male citizens below the age of 65 years:

Taxable Income (TI) in Rs.Income Tax in Rs.
Does not exceed 1,60,000NIL
Is greater than 1,60,000 and less than or equal to 5,00,00010% of the amount exceeding 1,60,000
Is greater than 5,00,000 and less than or equal to 8,00,00020% of the amount exceeding 5,00,000 + 34000
Is greater than 8,00,00030% of the amount exceeding 8,00,000 + 94000

Write a program to input the age, gender(male or female) and Taxable Income of the person. If the age is more than 65 years or the gender is female, display “wrong category”. If the age is less than or equal to 65 years and the gender is male, compute and display the Income Tax payable as per the table given above. Also if Income Tax calculated in over Rs.10,000/- then extra surcharge payable is 2% of the income tax.
Answer:

import java.util.*;
class Incometax
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter your gender m or f:");
char ch = sc.next().charAt(0);
if(ch==,f,||ch=='F')
{
System.out.printIn("Wrong Category");
}
else if(ch=='m||ch=-M')
{
System.out.print("Enter your age:");
int age = sc.nextInt(); if(age>65)
{
System.out.printIn("Wrong Category");
}
else
{
System.out.print("Enteryour income:");
double inc = sc.nextDouble();
double tax;
if(inc<=l 60000) { tax=0; } else if((inc> 160000)&&(inc<=500000)) { tax = (inc—160000)*0.1; 1 else if((inc>500000)&&(inc<=800000)) { tax = (inc-500000)*0.2; tax += 34000; } else { tax = (inc-800000)*0.3; tax += 94000; } if(tax > 10000)
tax+= tax* 0.02;
System.out.printIn("\nIncomeTax is INR "+tax);
}
else
{
System.out.printInC'Invalid Gender");
}
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

Question 6.
Define a class Customer described as below:
Data members/instance variables:
String card_holder: Name of the card holder, long cardjiolder: card Number
char card_type: type of card (Silver (S) / Gold (G) / Platinum (P)) double amt: purchase made using the card.

Member methods:
(i) Customer!): Default constructor to initialize all the date members
(ii) void input(): To accept the details of the card holder
(iii) void compute( ): To compute the cash back after availing the discount of a specific card type as per the following:

Card TypeCash Back
Silver (S)2% of purchase amount
Gold (G)5% of purchase amount
Platinum (P)8% of purchase amount

(iv) void display(): To display the details in the format:
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 2
Write a main method to create an object of the class and call the above member methods.
Answer:

import java.util.Scanner;
class Customer
{
String card_holder;
long card_no; charcard_type;
double amt- double cash_back;
public Customer()
{
card_holder="";
card_no =0;
card_type =' ';
amt = 0.0;
}
public void input()
{
Scanner scanner = new Scanner(System.in);
System.out.print("Enter customer name:");
card_holder = scanner.next();
System.out.printfEnter card number:");
card_no = scanner.nextInt();
System.out.print("Entertype of the card [S/G/P: ");
card_type = scanner.next().charAt(0);
System.out.print("Enter amount of purchase made using the card:");
amt = scanner.nextDouble();
}
public void compute()
{
if (card_type == ’S')
{
cash _back = amt * 0.02;
}
else if (card_type == 'G')
{
cash_back = amt * 0.05;
}
else if (card_type == 'P')
{
cash_back = amt * 0.08;
}
else
.{
System.out.printf'Invalid card type ");
}
}
public void display!)
{
System.out.printIn("Card Holder. \tCard Number. \t Card type \t Purchase Amount \t Cash back");
System.out.printIn(card_holder + "\t" + card_no + "\t" + card_type + "\t" + amt);
}
public void main()
{
Customer cl = new Customer();
cl.input();
cl.compute();
cl.display();
}

Question 7.
Accept a sentence and print a new sentence with all the odd placed words in uppercase and even placed words in lower case.
Sample input: It is a beautiful world
Sample output: IT is A beautiful WORLD
Answer:

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a string:");
String str = sc.nextLine();
String strl = str.toLowerCase();
str1+=" ";
String word =" ";
int count = 0;
for(int i =0; i < strl ,length();i++)
{
char ch = strl .charAt(i);
if(ch!='')
{
word+=ch;
}
else
{
count++; if (count %2 !=0)
{
System.out.print(word.toUpperCase()+"");
}
else
System.out.print(word+"");
word ="";
}
}
}
}

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

Question 8.
Using switch statement, write a menu driven program to
(i) Accept a number and find a sum of all the even numbers in the number.
Sample input: 24567
Sample output: Sum = 12 (2+4+6)
(ii) Accept a number and print those digits which are divisible by 3
Sample input: 135689
Sample output: Numbers divisible by 3 are 3,6, 9
Answer:

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
double sum = 0; int b =0;
System.out.printIn("Enter 1 for even number addition and 2 for printing numbers divisible by 3");
int ch = sc.nextIntO; switch(ch)
{
case '1int a = sc.nextInt();
b=a;
while(b % 10 !=0)
{
int temp = b %10;
if (temp %2 == 0)
sum+=temp; b = b/10;
}
System.out.printIn(sum);
break;
case '2': int k = sc.nextIntO;
b =k;
while(b %10 !=0)
{
int temp = b %10;
if (temp %3 == 0)
System.out.printIn(temp);
b = b/10;
}
break;
default: System.out.printIn("Error");
break;
}
}//end of main
}//end of class

Question 9.
Write a program to accept 50 student names and their school in two separate single dimension arrays. Search for the school name input by the user in the list. If found, display “Search Successful” and print the name of the school along with the student name, or else display the message “Search Unsuccessful.”
Answer:

import java.util.*;
class lol
{
public static void main()
{
String[ ] student_name = new String[50];
Stringt ] schooLname = new String[50];
Scanner sc = new Scanner(System.in);
forfint i = 0; i < 50; i++)
{
System.out.printInC'Enter students name :"); student_name[i] = sc.nextLine();
System.out.printInC'Enter schools name;"); school_name[i] = sc.nextLine();
}
System.out.printInC'Enter schools name you want to search:");
String str = sc.nextLine();
int flag =0;
for(int i =0; i < 50;i++)
{ if(school_name[i].compareTo(str)==0)
{ System.out.printInC'Search successful ");
System,out.printIn(school_name[i]+""+student_name[i]);
flag = 1 ;
break;
}
}
if (flag == 0)
System.out.printIn("Search Unsuccessful");
}
}

ICSE Class 10 Computer Application Sample Question Paper 4 with Answers

Question 10.
Design a class to overload a function pattern() as follows:
(i) void pattern(int n): with one int argument that prints the pattern as follows:
Input value of n = 5
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 3
(ii) void pattern (int n, char ch): with one int argument and one character argument to print the pattern as follows:
Input value of n = 5
Input value of ch =’*’ Output:
ICSE Class 10 Computer Application Sample Question Paper 4 with Answers 4
Answer:

import java.util.*;
public class Main
{
public void pattern(int n)
{
for(int i = n; i>0; i—)
{
for(intj = i;j<=n;j++)
System.out.print(j+"");
System.out.printIn();
}
}
public void pattern(int n, char ch)
{
for(int i = 1; i<n; i++)
{
for(int j = 1; j<=i*2; j++)
{
jf(j %2 == 0)
System.out.print(ch);
else
System.out.print(T');
}
System.out.printInO;
}
}
public static void main(String[ ] args)
{
System.out.printIn("Enter the value of n");
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
System.out.printIn("Enter the character");
char ch = sc.next().charAt(0);
Main ob = new Main();
ob.pattern(n);
ob.pattern(n,ch);
}//end of main
}//end of class
VariableData TypeDescription
chcharFor storing character m or f
ageintAge of person
incdoubleIncome of person
taxdoubleStore tax
cash__backdoubleTo store the cashback
clCustomerObject of class customer
strStringTo store line or sentence
countintStore number of words
sumdoubleStore the sum of series
a,b,kIntGet the number.
student_name,

school_name

StringArray to store student name and school name
flagintTo know name exists or not
ijintFor looping
nintNumber of times to be printed
chcharStoring character
obMainObject of class Main

ICSE Class 10 Computer Application Question Papers with Answers

Leave a Comment