ICSE Computer Applications Question Paper Solved for Class 10

Solving ICSE Class 10 Computer Applications Previous Year Question Papers ICSE Class 10 Computer Applications Question Paper 2015 is the best way to boost your preparation for the board exams.

ICSE Class 10 Computer Applications Question Paper 2015 Solved

Section – A (40 Marks)
(Attempt all Questions)

Question 1.
(a) What are the default values of the primitive data type int and float? [2]
Answer:

  • Default value of the data type int is 0.
  • Default value of the data type float is 0.0f.

ICSE 2015 Computer Applications Question Paper Solved for Class 10

(b) Name any two OOP s principles. [2]
Answer:
Object-Oriented Programming is a methodology or paradigm to design a program using classes and objects. OOP principles are :

  • Data Abstraction
  • Encapsulation

(c) What are identifiers ? [2]
Answer:
An identifier is a name given to a package, class, interface, method, or variable. It allows a programmer to refer to the item from other places in the program. An identifier is a sequence of one or more characters. The first character must be a valid first character.

(d) Identify the literals listed below: [2]
(i) 0.5 (ii) ‘A’ (iii) false (iv) “a”.
Answer:
(i) Float
(ii) Character
(iii) Boolean
(iv) String

(e) Name the wrapper classes of char type and boolean type. [2]
Answer:

  • Wrapper class of char is Character.
  • Wrapper class of boolean is Boolean.

Question 2.
(a) Evaluate the value of n if value of p = 5, q = 19
int n = (q – p) >(p-q) ? (q – p) : (p – q) ; [2]
Answer:
14

(b) Arrange the following primitive data types in an ascending order of their size:
(i) char
(ii) byte
(iii) double
(iv) int. [2]
Answer:
char is 2 bytes in size,
byte is I byte in size,
double is 8 bytes in size.
int is 4 bytes in size.
Therefore, the ascending order is byte, char, int, double.

ICSE 2015 Computer Applications Question Paper Solved for Class 10

(c) What is the value stored in variable res given below :
double res = Math.pow (“345”.indexOf(‘5), 3); [2]
Answer:
8.0

(d) Name the two types of constructors. [2]
Answer:
Default constructor, Parameterized constructor.

(e) What are the values of a and b after the following function is executed, if the values passed are 30 and 50: [2]
void paws (int a, int b)
{ a = a + b;
b = a – b;
a = a – b;
System.out.println(a + “, ”+b) ;
}
Answer:
50, 30

Question 3.
(a) State the data type and value of y after the following is executed:
char x = ‘7’;
y = Character.isLetter(x) ; [2]
Answer:
Data type of y is boolean and value is false.

(b) What is the function of catch block in exception handling? Where does it appear in a program? [2]
Answer:
You can associate exception handlers with a try block by providing one or more catch blocks directly after the try block. No code can be between the end of the try block and the beginning of the first catch block. The catch block appears just after the try block.
fry {
} catch (ExceptionType name) {
} catch (ExceptionType name) {
}

(c) State the output when the following program segment is executed:
String a = “Smartphone”, b = “Graphic Art”;
String h = a.substring(2, 5) ;
String k = b.substring(8).toUpperCase() ;
System.out.println(h);
System.out.println(k.equalsIgnore Case(h)); [2]
Answer:
art
true

ICSE 2015 Computer Applications Question Paper Solved for Class 10

(d) The access specifier that gives the most accessibility is ………………………….. and the least accessibility is …………………… .[2]
Answer:
public,
private

(e) (i) Name the mathematical function which is used to find sine of an angle given in radians.
(ii) Name a string function which removes the blank spaces provided in the prefix and suffix of a string. [2]
Answer:
(i) Math.sin()
(ii) trim()

(f) (i) What will this code print ?
int arr[] = new int [5];
System, out.print In (arr);
(i) 0
(ii) value stored in arr[0]
(iii) 0000
(iv) garbage value
(ii) Name the keyword which is used to resolve the conflict between method parameter and instance variables /fields. [2]
Answer:
(i) garbage value
(ii) The this keyword

(g) State the package that contains the class :
(i) BufferedReader
(ii) Scanner [2]
Answer:
(i) java.io
(ii) java.util.Scanner

(h) Write the output of the following program code: [2]
char ch: ‘
do
{
ch=(char) x ;
System.out.print(ch + ” “);
if(x% 10 == 0)
break;
++x;
} while (x<=100);
Answer:
a

(i) Write the Java expressions for: \(\frac{a^2+b^2}{2 a b}\)
Answer:
Math.pow(a, 2) + Math.pow(b, 2)/(2*a*b);

(j) If int y = 10 then find int z = (++y *(y++ +5));
Answer:
176

ICSE 2015 Computer Applications Question Paper Solved for Class 10

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

Question 4.
Define a class called Parking Lot with the following description:
Instance variables / data members:
int vno – To store the vehicle number
int hours – To store the number of hours the vehicle is parked in the parking lot
double bill: To store the bill amount
Member methods:
void input() – To input and store the vno and hours.
void calculate () – To compute the parking charge at the rate of ₹ 3 for the first hour or part thereof and ₹ 1.50 for each additional hour or part thereof.
void display() – To display the detail Write a main method to create an object of the class and call the above methods. [15]
Answer:

import java.io.*;
class ParkingLot {
private int vno;
private int hours;
private double bill;
void input() throws IOException {
BufferedReader reader = new Buffered Reader(new InputStreamReader (System.in));
System.out.println("Enter the vehicle number::");
String y = reader.readLine();
vno = lnteger.parselnt(y);
System.out.println("Enter number of hours::");
String r =reader.readLine();
hours=lnteger.parseInt(r);
} .
void calculate() {
if(hours<=0) {
System.out.println("Wrong Input");
System.exit(0);
}
else if(hours >0 && horns <=1) {
System.out.println("Parking Charges-');
bill = hours*3.0;
}
else {
System.out.println("Parking Charges =");
bill = 3.0+(hours-1)*3;
System.out.println(+ bill);
}
}
void display() {
System.out.println("Vehicle Number:: " +vno);
System.out.println("Total Time:: " +hours);
System.out.println("Total Charges:: " +bill);
}
public static void main(String args[]) throws IOException {
ParkingLot pk = new ParkingLot(); //creation of object
pk.input();
pk.calculate();
pk.display();
System.out.println();
}
}
ICSE 2015 Computer Applications Question Paper Solved for Class 10

Question 5.
Write two separate programs to generate the following patterns using iteration (loop) statements:
(a)
ICSE 2015 Computer Applications Question Paper Solved for Class 10 1
Answer:

class Test {
public static void main(String args[]) {
int n, c, k, space, count = 1;
n=5;
space = n;
for(c = 1 ; c <= n; C++) {
for( k = 1 ; k < space ; k++)
System.out.print(" ");
for (k = 1 ; k <= c; k++) {
System.out.print("*");
k++;
if ( c > 1 && count++ < c) {
System.out.print("#");
count++;
}
}
System.out.print("\n");
space- -;
count =1;
}
}
}

(b)
ICSE 2015 Computer Applications Question Paper Solved for Class 10 2
Answer:

class Pattem2 {
public static void main(String args[]) {
int ij;
int rows=5;
for (i = 1 ; i <= 5 ; i++) {
for (j = (rows + 1 - i) ; j >0;j--){
System.out.print(j);
}
System.out.println();
}
}
}

Question 6.
Write a program to input and store roll numbers, names and marks in 3 subjects of n number students in five single dimensional array and display the remark based on average marks as given below : (The maximum marks in the subject are 100) [15]
Average marks = \(=\frac{\text { Tatal marks }}{3}\)

Average mark Remark
85-100 EXCELLENT
75-84 DISTINCTION
60-74 FIRST CLASS
40-59 PASS
Less than 400 POOR

Answer:

import java.io.*;
class ScoreCard {
public static void travel() throws IOException {
String namef] = new String[15];
int rollnof] = new int[15];
int subjectl[] = new int[15];
int subject2[] = new int[15];
int subject3[] = new int[15];
double average[]=new doublet 15];
int i;
BufferedReader buf = new Buffered
Reader(new InputStreamReader (System.in));
//The for loop will accept the names and details for 15 students.
for(i=0; i<15; i++) {
System.out.println("Name of the Student::");
name[i] = but.readLine();
System.out.println("Roll Number::");
String r = buf.readLine();
rollno[i] = Integer.parselnt(r);
System.out.println("Marks in Subject 1 ::");
String ml = buf.readLine();
subject l[i] = Integer.parselnt(ml);
System.out.println("Marks in Subject 2 ::");
String m2 buf.readLine();
subject2[i] = Integer.parselnt(m2);
System.out.println("Marks in Subject 3 ::");
String m3 = buf.readLine();
subject3[i] = Integer.parselnt(m3);
average[i] = (subject 1 [i] + subject2[i] + subject3[i])/3;
if(average[i] >= 85 && average[i] <=100) {
System.out.println("EXCELLENT");
}
else if(average[i] >=75 && average[i] <= 84){
System.out.println("DISTINC- TION");
}
else if(average[i] >= 60 && average[i] <= 74){
System.out.println("FIRST CLASS");
}
else iffaveragefi] >= 40 && average[i] <= 59){
System.out.println("PASS");
}
else
System.out.println("POOR");
}
}
}

ICSE 2015 Computer Applications Question Paper Solved for Class 10

Question 7.
Design a class to overload a function Joystring () as follows:
(i) void Joystring (String s, char chi, char ch2) with one string argument and two character arguments that replaces the character argument chi with the character argument ch2 in the given string s and prints the new string.
Example:
Input value ofs = “TECHNALAGY”
ch1 = ‘A’,
ch2 = ‘O’
Output: “TECHNOLOGY”
Answer:

class OverLoading {
void Joystring(String s, char chi, char ch2) {
System.out.println("Entered String is:");
System.out.println(s);
System.out.println("New String is:");
System.out.println(s.replace(ch 1 ,ch2));
}

(ii) void Joystring (String s) with one string argument that prints the position of the first space and the last space of the given string s.
Example:
Input value of = “Cloud computing means Internet based computing”
Output: First index: 5
Last index: 36
Answer:

void Joystring(String s) {
System.out.print("Entered String is:");
System.out.println(s);
System.out.println("Char 'First Space' at first occurance: "+s.indexOf(' '));
System.out.println("Char 'Last Space' at Lastoccurance: "+s.lastIndexOf(' '));
}

(iii) void Joystring (String si, String s2) with two string arguments that combines the two strings with a’ space between them and prints the resultant string. [15]
Example:
Input value of s1 = “COMMON WEALTH”
Input value of s2 = “GAMES”
Output: COMMON WEALTH GAMES
(use library Junctions)
Answer:

void Joystring(String si, String s2) {
String s3= " "; //creating a blank space
String s4 = sl.concat(s3); //adding a blank
space to first String.
String s5 = s4.concat(s2);
System.out.println("String concat using String
concat method : " + s5);
}
}

Question 8.
Write a program to input twenty names in an array. Arrange these names in descending order of alphabets, using the bubble sort technique. [15]
Answer:

import java.io.*;
class BubbleSorting {
public static void main(String argsf]) throws IOException {
String name[] = new String[20];
int i;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Name=");
for(i=0;i<name.length;i++)
name[i] = br.readLine();
//Showing the entered names.
System.out.print("EnteredNames are=");
for(i=0;i<name.length;i-H-) {
System.out.print(" " +name[i]);
}
for(int k=0;k<name.length;k++) {
for(int j=0;j<name.length-1 ;j++) {
if((name[j].compareTo(name[j+1]))>0) {
String temp;
temp = name[j];
name[j]=name[j+1];
name[j+1 ]=temp;
}
}
}
System.out.println("The sorted names are= ");
for(i=0;i<name.length;i++) {
System.out.println(name[i]+ " ");
}
}
}

ICSE 2015 Computer Applications Question Paper Solved for Class 10

Question 9.
Using the switch statement, write a menu driven program to:
(i) To find and display all the factors of a number input by the user (including 1 and excluding number itself).
Example:
Sample Input: n = 15
Sample Output: 1, 3, 5

(ii) To find and display the factorial of a number input by the user (the factorial of a non-negative integer n, denoted by n !, is the product of all integers less than or equal to n.
Example:
Sample Input: n = 5
Sample Output: 5! = 1 × 2 × 3 × 4 × 5 = 120.
For an incorrect choice, an appropriate error message should be displayed. [15]
Answer:

import java.io.*;
class SwitchStatement { 
public static void main(String args[]) throws lOException { 
System.out.println("******** Factors and Factorial Program *********"); 
InputStreamReader reader = new Input StreamReader(System.in); 
BufferedReader input = new Buffered Reader(reader);
System.out.println("l. Factor of a Number"); 
System.out.println("2. Factorial of a Number"); 
System.out.println();
System.out.println(”Enter your choice::");
String x = input.readLine(); 
int ch = Integer.parselnt(x); 
switch(ch) { 
case 1: 
int i;
System.out.print("Enter the number: ");
String a = input.readLine(); 
int n = Integer.parselnt(a); 
System.out.print("The factors are : "); 
for(i=1;i<=n/2;i++) {
if(n%i==0)
System.out.print(i+","); .
}
System.out.print(n); 
break; 
case 2:
int numb=0, count, fact = 1; 
System.out.println("Enter an integer to calculate it's factorial");
System.out.println("Enter the no. of terms");
String t = input.readLine(); 
numb = Integer.parselnt(t);
{
for (count = 1 ; count <= numb; count++ ) 
fact = fact*count;
System.outprintIn("Factorial of "+numb+" is = "+fact);
}
}
}