ICSE Class 10 Computer Applications 2018 Solved Paper

ICSE Solved Papers

ICSE Class 10 Computer Applications 2018 Solved Paper

ICSE Class 10 Computer Applications 2018 Solved Question Paper

If you have any doubts, ask them in the comments section at the bottom of this page.

ICSE Class 10 Computer Applications 2018 Solved Paper
Computer Applications
Class X

SECTION A (40 Marks)
Answer all questions from this Section

Attempt all questions

Question 1:
(a) Define abstraction. [2]
Ans. Abstraction refers to specifying the behaviour of a class without going into the details of the implementation.
(b) Differentiate between searching and sorting. [2]
Ans. In searching, we are provided with an array which contains multiple elements and asked to find the index of a specific element.
In sorting, an array is provided and we are asked to order the elements in either ascending or descending order.
(c) Write a difference between the functions isUpperCase() and toUpperCase(). [2]
Ans. Both isUpperCase() and toUpperCase() are functions of the Character class.
isUpperCase() accepts a character and returns true if the provided character is uppercase. Else, it returns false.

boolean b1 = Character.isUpperCase('a');
boolean b2 = Character.isUpperCase('A');
System.out.println(b1 + " " + b2);

will print

false true

(d) How are private members of a class different from public members? [2]
Ans. Private members of a class can be accessed only by the methods of the class in which they are declared. While public members can be accessed outside of the class also.
(e) Classify the following as primitive or non-primitive data types: [2]
(i) char
(ii) arrays
(iii) int
(iv) classes
Ans. (i) char – Primitive
(ii) arrays – Non primitive
(iii) int – Primitive
(iv) Classes – Non proimitive
Question 2
(a) (i) int res = ‘A’;
What is the value of res?
(ii) Name the package that contains wrapper classes. [2]
Ans. (i) res will hold the ASCII value of ‘A’ which is 65.
(ii) java.lang package contains wrapper classes.
(b) State the difference between while and do-while loop. [2]
Ans. A while is an entry controlled loop i.e. the loop condition is checked before the loop is executed while do-while is an exit controlled loop i.e. the loop condition is checked after the loop is executed.
Because of this a do-while loop gets executed atleast once which is not true for a while loop.
(c) System.out.print(“BEST “);
System.out.println(“OF LUCK”);
Choose the correct option for the output of the above statements: [2]
(ii) BEST
Ans. (i) is the correct output.
System.out.print() does not add a new line at the end because of which ‘OF LUCK’ gets printed on the same line as ‘BEST’.
(d) Write the prototype of a function check which takes an integer as an argument and returns a character. [2]

char function(int a)

(e) Write the return data type of the following functions: [2]
(i) endsWith()
(ii) log()
Ans. i) boolean
ii) double
Question 3
(a) Write a Java expression for the following: [2]
(3x + x²) / (a + b)
Ans. Math.sqrt(3 * x + Math.pow(x, 2)) / (a + b)
(b) What is the value of y after evaluating the expression given below? [2]
y += ++y + y– + –y; when int y = 8.
y += ++y + y– + –y
y = 8 + ++y + y– + –y
y = 8 + 9 + 9 + 7
y = 33
(c) Give the output of the following: [2]
(i) Math.floor(-4.7)
(ii) Math.ceil(3.4) + Math.pow(2, 3)
Ans. i) -5.0
ii) 4.0 + 8.0 = 12.0
(d) Write two characteristics of a constructor. [2]
Ans. i) A constructor has the same name as that of the class
ii) A constructor does not have a return type
(e) Write the output for the following: [2]
System.out.println(“Incredible” + “\n” + “world”);


(f) Convert the following if else if construct into switch case: [2]

if(var == 1)
else if(var == 2)
else if(var == 3)


switch(var) {
case 1:
case 2:
case 3:

(g) Give the output of the following string functions: [2]
(i) “ACHIEVEMENT”.replace(‘E’, ‘A’)
(ii) “DEDICATE”.compareTo(“DEVOTE”)
ii) The first two characters are same. So, we take the ASCII values of the third characters and subtract to get the result.
D – V = 68 – 86 = -18
(h) Consider the following String array and give the output: [2]

String arr[] = {"DELHI", "CHENNAI", "MUMBAI", "LUCKNOW", "JAIPUR"};
System.out.println(arr[0].length() > arr[3].length());
System.out.print(arr[4].substring(0, 3));

System.out.println(arr[0].length() > arr[3].length());
arr[0].length() > arr[3].length()
“DELHI”.length() > “LUCKNOW”.length()
5 > 7 , which is false
Output is false
System.out.print(arr[4].substring(0, 3));
JAIPUR.substring(0, 3)
Output is JAI
(i) Rewrite the following using ternary operator: [2]

if(bill > 10000)
discount = bill * 10.0 / 100;
discount = bill * 5.0 / 100;


discount = bill > 10000 ? (bill * 10.0 / 100) : (bill * 5.0 / 100);

(j) Give the output of the following program segment and also mention how many times the loop is executed: [2]

int i;
for(i = 5; i > 10; i++)
System.out.println(i * 4);

Loop condition i > 10 evaluates to 5 > 10 which is false. So, loop is not executed even once
System.out.println(i * 4) prints 5 * 4 = 20

SECTION B (60 Marks)

ICSE Class 10 Computer Applications 2018 Solved Paper
Attempt any four questions from this Section.

Question 4
Design a class RailwayTicket with the following description:
Instance variables/data members:
String name: to store the name of the customer.
String coach: to store the type of coach customer wants to travel.
long mobno: to store customer’s mobile number.
int amt: to store basic amount of ticket.
int totalamt: to store the amount to be paid after updating the original amount.
void accept(): to take input for name, coach, mobile number and amount.
void update(): to update the amount as per the coach selected. Extra amount to be added in the amount as follows:
Type of coaches Amount
First_AC 700
Second_AC 500
Third_AC 250
sleeper None
void display(): To display all details of a customer such as name, coach, total amount and mobile number.
Write a main() method to create an object of the class and call the above methods.

import java.util.Scanner;
class RailwayTicket 
 String name;
 String coach;
 long mobno;
 int amt;
 int totalamt;
 void accept()
   Scanner scanner = new Scanner(;
   System.out.print("Enter name: ");
   name = scanner.nextLine();
   System.out.print("Enter coach:(Type 1A for first class, 2A for second class, 3A for third class & SL for Sleeper class) ");
   coach = scanner.nextLine();
   System.out.print("Enter mobno: ");
   mobno = scanner.nextLong();
   System.out.print("Enter amt: ");
   amt = scanner.nextInt();
 void update()
   if (coach.equals("1A"))
     totalamt = amt + 700;
   else if (coach.equals("2A"))
     totalamt = amt + 500;
   else if (coach.equals("3A"))
     totalamt = amt + 250;
   else if (coach.equals("SL"))
     totalamt = amt;
 void display()
   System.out.println("Name: " + name);
   System.out.println("Coach: " + coach);
   System.out.println("Mobile Number: " + mobno);
   System.out.println("Amount: " + amt);
   System.out.println("Total Amount: " + totalamt);
 public static void main(String args[])
   RailwayTicket rt = new RailwayTicket();
   rt.accept(); rt.update(); rt.display();


Sample output:

Enter name: Aryan
Enter coach: 1A
Enter mobno: 8888992299
Enter amt: 3000
Name: Aryan
Coach: 1A
Mobile Number: 8888992299
Amount: 3000
Total Amount: 3700

Question 5
Write a program to input a number and check and print whether it is a Pronic number or not. Pronic number is the number which is the product of two consecutive integers.
12 = 3 × 4
20 = 4 × 5
42 = 6 × 7

import java.util.Scanner;
public class PronicNumber {
	public static void main(String[] args) {
		Scanner kb = new Scanner(;
		System.out.print("Enter number: ");
		int n = kb.nextInt();
		int c=0;
		for (int i = 1; i<n; i++) {
			int product = i * (i + 1);
			if (product == n) {
			System.out.println(+n+" is a Pronic number");
			System.out.println(+n+" is not a Pronic number");

Sample output

Enter number: 42
42 is a Pronic number

Question 6
Write a program in Java to accept a string in lowercase and change the first letter of every word to uppercase. Display the new string.
Sample INPUT: we are in cyber world
Sample OUTPUT: We Are In Cyber World

import java.util.Scanner;
class SentenceCase {
public static void main(String[] args) {
Scanner kb = new Scanner(;
System.out.print("Enter a sentence: ");
String sentence = kb.nextLine();
String output = "";
for (int i = 0; i<sentence.length(); i++) {
char ch = sentence.charAt(i);
if (i == 0 || sentence.charAt(i - 1) == ' ') {
output = output + Character.toUpperCase(ch);
else {
output = output + ch;
System.out.println("Output: " + output);

Sample output

Enter a sentence: we are in cyber world
Output: We Are In Cyber World

Question 7 Design a class to overload a function volume() as follows:
(i) double volume(double r) – with radius ‘r’ as an argument, returns the volume of sphere using the formula: v = 4 / 3 × 22 / 7 × r³
(ii)double volume(double h, double r) – with height ‘h’ and radius ‘r’ as the arguments, returns the volume of a cylinder using the formula: v = 22 / 7 × r² × h
(iii) double volume(double l, double b, double h) – with length ‘l’, breadth ‘b’ and height ‘h’ as the arguments, returns the volume of a cuboid using the formula: v = l × b × h

public class Overload {
double volume(double r) {
double vol = 4.0 / 3 * 22 / 7 * Math.pow(r, 3);
return vol;
double volume(double h, double r) {
double v = 22.0 / 7 * Math.pow(r, 2) * h;
return v;
double volume(double l, double b, double h) {
double v = l * b * h;
return v;

Question 8 Write a menu-driven program to display the pattern as per user’s choice:
Pattern 1        Pattern 2
ABCDE           B
ABCD              LL
ABC                 UUU
AB                    EEEE
For an incorrect option, an appropriate error message should be displayed.

import java.util.Scanner;
class Pattern{
	public static void main(String[]args){
		int choice;
		char k;
		Scanner kb=new Scanner(;
		System.out.print("Enter Pattern no. 1 or 2: ");
			case 1:System.out.print("Enter number of lines: ");
                               int n = kb.nextInt();
                               for(int i=1;i<=n;i++)
						for(int j=1;j<=n;j++)
								System.out.print(" ");
			case 2: System.out.print("Enter a String: ");
					for(int i=0;i<s.length();i++)
						char c=s.charAt(i);
						for(int j=0;j<s.length();j++)
								System.out.print(" ");
			default: System.out.println("Invalid");

Sample output 1

Enter pattern number: 1
Enter number of lines: 5

Sample output 2

Enter pattern number: 2
Enter string: BLUE

Sample output 3

Enter pattern number: 3
Invalid choice

Question 9
Write a program to accept name and total marks of N number of students in two single subscripts array name[] and totalmarks[].
Calculate and print:
(i) The average of the total marks obtained by N number of students.
[average = (sum of total marks of all the students) / N]
(ii) Deviation of each student’s total marks with the average.
[deviation = total marks of a student – average]

import java.util.Scanner;
class Student {
public static void main(String[] args) {
Scanner kb = new Scanner(;
System.out.print("Enter number of students: ");
int n = kb.nextInt();
String[] name = new String[n];
int[] totalmarks = new int[n];
for (int i = 0; i<n; i++) {
System.out.println("Student " + (i + 1));
System.out.print("Enter name: ");
name[i] =;
System.out.print("Enter marks: ");
totalmarks[i] = kb.nextInt();
int sum = 0;
for (int i = 0; i<n; i++) {
sum = sum + totalmarks[i];
double average = (double) sum / n;
System.out.println("Average is " + average);
for (int i = 0; i<n; i++) {
double deviation = totalmarks[i] - average;
System.out.println("Deviation of " + name[i] + " is " + deviation);

Sample output

Enter number of students: 3
Student 1
Enter name: Aryan
Enter marks: 95
Student 2
Enter name: Shashank
Enter marks: 99
Student 3
Enter name: Atharv
Enter marks: 94
Average is 96.0
Deviation of Aryan is -1.0
Deviation of Shashank is 3.0
Deviation of Atharv is -2.0

Checkout 10 years Solved Question Papers ICSE 10 Years Solved Papers
Download Question Paper

Comments (15)

  1. Jayant Singh

    In question number 6 can programing be done by using while loop

    1. admin

      Yes u can but using for loop will save lots of time

  2. Shriyanshi Gupta

    Why you have again created a class in question no 4 line 42

    1. admin

      Hey Shriyanshi, since in question it is asked to create an object of a RailwayTicket class, So if we define our main method within same class, then we don’t need to call the method by object of the class in which these methods (accept, update, display) belongs to.
      So in order to call any non-static method of a class , we need to first create an object of the class in which these methods are defined

  3. Pari Kesarwani

    any one refrence data type?

    1. admin


  4. Asim

    sir how to check for twisted prime

    1. admin
      import java.util.Scanner;
      class TwistedPrime{
      	public static void main(String[]args)
      		Scanner kb=new Scanner(;
      		int r,n1,n2=0,count1=0,count2=0;
      		boolean flag1=false,flag2=false;
      		System.out.print("Enter a no. ");
      		for(int i=2;i0)	//loop to reverse the no.
      				n2 = (n2*10)+r;	//n2 will be the reversed no.
      		for(int i=2;i
  5. mohit patel

    how to split words from a sentence

    1. admin

      will you elaborate you question ??

  6. Basanti Barik

    Sir how can we split 321 in java and swap it by string

  7. Shubham Tripathi

    u meant, Reversing the number 321

  8. Spur

    I did not understand Q 9

  9. Shubham Tripathi

    then u should enroll in our online class

  10. Shirisha

    Sir how to print the pattern below:

Leave your thought here

Your email address will not be published. Required fields are marked *

error: Content is protected !!