ICSE Class 10 Computer Applications ( Java ) 2017 Solved Question Paper

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

ICSE Question Paper – 2017 (Solved)
Computer Applications
Class X

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

SECTION A (40 MARKS)
Attempt all questions

Question 1:
a) What is Inheritance ? [2]
Ans. Inheritance is the process by which one class extends another class to inherit the variables and functions and add any additional variables and methods.

b) Name the operators listed below [2]
i) < ii) ++ iii) && iv) ?:

Ans. i) Less than comparison operator
ii) Increment operator
iii) And logical operator
iv) Ternary operator

c) State the number of bytes occupied by char and int data types.[2]
Ans. char occupies two bytes and int occupied 4 bytes.

d) Write one difference between / and % operator. [2]
Ans. / is division operator while % is modulus operator which gives the remainder on dividing two numbers.

e) String x[] = {“SAMSUNG”, “NOKIA”, “SONY” , “MICROMAX”, “BLACKBERRY”};
Give the output of the following statements:
i) System.out.println(x[1]);
ii) System.out.println(x[3].length()); [2]

Ans. i) NOKIA
ii) “MICROMAX”.length() = 8

Question 2:
a) Name of the following: [2]
i) A keyword used to call a package in the program.
ii) Any one reference data types.

Ans. i) import
ii) String

b) What are the two ways of invoking functions? [2]
Ans. Call by value and call by reference

c) State the data type and value of res after the following is executed : [2]

char ch = 't';
res = Character.toUpperCase(ch);

Ans. Data type of res is char and value is T

d) Give the output of the following program segment and also mention the number of times the loop is executed: [2]

int a,b;
for(a=6,b=4;a<=24;a=a+6)
{
          if(a%b==0)
         break;
}
System.out.println(a);

Ans.

Loop initialization: a = 6, b = 4

First iteration:
Condition check: a <= 24 --- 6 <= 24 ---- true
Loop is executed for the first time
Loop execution: a % b = 6 % 4 = 2 != 0 Hence, break is not executed
Loop increment operator: a = 1 + 6 --- a = 6 + 6 = 12

Second iteration:
Condition check: a <= 24 --- 12 <= 24 ---- true
Loop is executed for the second time
Loop execution: a % b = 12 % 4 = 0 = 0 Hence, break is executed
System.out.println(a); --- 12

Output is 12 and loop is executed two times

e) Write the Output: [2]

char ch= 'F';
int m=ch;
m=m+5;
System.out.println(m+ " " +ch);

Ans. ch = ‘F’
int m = ch; — ASCII value of ‘F’ i.e. 70 will be assigned to m
m = m + 5 = 70 + 5 = 75
System.out.println(m+ ” ” +ch); — 75 F
Output is
75 F

Question 3:
a) Write a Java expression for the following : [2]
ax5 + bx3 + c

Ans. a * Math.pow(x, 5) + b * Math.pow(x, 3) + c

b) What is the value of x1 if x=5 ? [2]
x1=++x – x++ + –x

Ans. x1=++x – x++ + –x
x1 = 6 (x is incremented to 6) – 6 (x is incremented to 7) + 6 (x is decremented to 6)
= 6

c) Why is an object called an instance of a class? [2]
Ans. An object is called an instance of a class as every object created from a class gets its own instances of the variables defined in the class. Multiple objects can be created from the same class.

d) Convert following do-while loop into for loop. [2]

int i=1;
int d=5;
do{
d=d*2
System.out.println(d);
i++;
}while(i<=5);

Ans.

for(int i=1, d=5; i<=5; i++) {
   d = d * 2;
   System.out.println(d);
}

e) Differentiate between constructor and function. [2]
Ans. The constructor of a class is invoked automatically during object creation while a function is invoked manually after object creation.
A constructor is invoked only once while a function can be invoked multiple times.
A constructor has the same name as the class in which it is defined while a function can have any name.

f) Write the output for the following: [2]

String s= "Today is Test";
System.out.println(s.indexOf('T'));
System.out.println(s.substring(0,7)+ "  "+ "Holiday");

Ans.
s.indexOf(‘T’) = 0
s.substring(0,7)+ ” “+ “Holiday”
= “Today is Test”.substring(0,7) + ” ” + “Holiday”
= “Today i” + ” ” + “Holiday”
= “Today i Holiday”
Output is
0
Today i Holiday

g) What are the values stored in variables r1 and r2: [2]
i) double r1 = Math.abs(Math.min(-2.83,-5.83));
ii) double r2 = Math.sqrt(Math.floor(16.3));

Ans. i) double r1 = Math.abs(Math.min(-2.83,-5.83));
= Math.abs(-5.83)
= 5.83
ii) double r2 = Math.sqrt(Math.floor(16.3));
= Math.sqrt(16)
= 4.0

h) Give the output of the following code: [2]

String A= "26", B= "100" ;
String D=A+B+ "200";
int x= Integer.parseInt(A);
int y=Integer.parseInt(B);
int d=x+y;
System.out.println("Result 1=" +D);
System.out.println("Result 2="+d);

Ans.
String A= “26″, B= “100″ ;
A = “26″, B = “100″

String D=A+B+ “200″;
D = “26″ + “100″ + “200″ = 26100200

int x= Integer.parseInt(A);
x = Integer.parseInt(“26″) = 26

int y=Integer.parseInt(B);
y= Integer.parseInt(B) = Integer.parseInt(“100″); = 100

int d=x+y;
d = 26 + 100 = 126

System.out.println(“Result 1=” +D);
Result 1=26100200

System.out.println(“Result 2=”+d);
Result 2=126

Output is

Result 1=26100200
Result 2=126

i) Analyze the given program segment and answer the following questions [2]

for(int i=3;i<=4;i++)
{
for(int j=2;j<i;j++)
{
System.out.print(" ");
}
System.out.println("WIN");
}

i) How many times does the inner loop execute ?
ii) Write the output of the program segment.

Ans. The output loop runs twice, with i = 3 and i = 4
When i = 3, the inner loop runs once with j = 2
When i = 4, the inner loop runs twice with j = 2 and j = 3

i) Inner loop executes 3 times
ii)

 WIN
  WIN

j) What is the difference between the Scanner class functions next() and nextLine()? [2]
Ans. next() read a single token i.e. all characters from the current position till a whitespace or tab or new line is encountered.
nextLine() reads an entire line i.e. all characters from the current position till a new line is encountered.

SECTION B (60 Marks)
Attempt any four questions from this Section.
The answers in this section should consist of the programs in either BlueJ environment or any program environment with Java as the base.
Each program should be written using Variable descriptions/Mneumonic codes so that the logic of the program is clearly depicted.
Flow-charts and algorithms are not required.

Question 4.
Define a class Electric Bill with the following specifications: [15]
class: ElectricBill
Instance Variable/ data member:
String n – to store the name of the customer
int units – to store the number of units consumed
double bill – to store the amount to paid
Member methods:
Void accept() – to accept the name of the customer and number of units consumed
Void calculate() – to calculate the bill as per the following tariff :
Number of units — Rate per unit
First 100 units — Rs.2.00
Next 200 units — Rs.3.00
Above 300 units — Rs.5.00
A surcharge of 2.5% charged if the number of units consumed is above 300 units.
Void print() – To print the details as follows :
Name of the customer ………
Number of units consumed ……
Bill amount …….
Write a main method to create an object of the class and call the above member methods.

Ans.

import java.util.Scanner;

public class ElectricBill {

	private String n;
	private int units;
	private double bill;

	public void accept() {
		Scanner scanner = new Scanner(System.in);
		System.out.print("Enter name: ");
		n = scanner.next();
		System.out.print("Enter units: ");
		units = scanner.nextInt();
	}

	public void calculate() {
		if (units <= 100) {
			bill = units * 2;
		} else if (units > 100 && units <= 300) {
			bill = 100 * 2 + (units - 100) * 3;
		} else {
			bill = 100 * 2 + 200 * 3 + (units - 300) * 5;
			double surcharge = bill * 2.5 / 100;
			bill = bill + surcharge;
		}
	}

	public void print() {
		System.out.println("Name of the customer: " + n);
		System.out.println("Number of units consumed: " + units);
		System.out.println("Bill amount: " + bill);
	}

	public static void main(String[] args) {
		ElectricBill electricBill = new ElectricBill();
		electricBill.accept();
		electricBill.calculate();
		electricBill.print();
	}
}

Sample output

Enter name: Sai
Enter units: 50
Name of the customer: Sai
Number of units consumed: 50
Bill amount: 100.0

Question 5.

Write a program to accept a number and check and display whether it is a spy number or not. [15]
(A number is spy if the sum its digits equals the product of the digits.)
Example: consider the number 1124 , sum of the digits = 1 + 1 + 2 + 4 = 8
Product of the digits = 1 X 1 X 2 X 4=8

Ans.

import java.util.Scanner;

public class SpyNumber {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.print("Enter number: ");
		int n = scanner.nextInt();

		int sumOfDigits = 0;
		int productOfDigits = 1;
		while (n > 0) {
			int remainder = n % 10;
			sumOfDigits = sumOfDigits + remainder;
			productOfDigits = productOfDigits * remainder;
			n = n / 10;
		}

		if (sumOfDigits == productOfDigits) {
			System.out.println("Spy number");
		} else {
			System.out.println("Not a spy number");
		}
	}
}

Sample output 1

Enter number: 1124
Spy number

Sample output 2

Enter number: 34
Not a spy number

Question 6.
Using switch statement, write a menu driven program for the following: [15]
i) To find and display the sum of the series given below:
S = x1 – x2 + x3 – x4 + x5 … – x20
(where x=2)
ii) To display the following series:
1 11 111 1111 11111
For an incorrect option, an appropriate error message should be displayed.

Ans.

import java.util.Scanner;

public class Menu {
	public static void main(String[] args) {
		System.out.println("1. Sum of series");
		System.out.println("2. Display Series");
		System.out.print("Enter your choice: ");
		Scanner scanner = new Scanner(System.in);
		int choice = scanner.nextInt();
		switch (choice) {
		case 1:
			double sum = 0;
			for (int i = 1; i <= 20; i++) {
				if (i % 2 == 1) {
					sum = sum + Math.pow(2, i);
				} else {
					sum = sum - Math.pow(2, i);
				}
			}
			System.out.println("Sum = " + sum);
			break;
		case 2:
			for (int i = 1; i <= 5; i++) {
				for (int j = 1; j <= i; j++) {
					System.out.print("1");
				}
				System.out.print(" ");
			}
			break;
		default:
			System.out.println("Invalid choice");
			break;
		}
	}
}

Sample output 1

1. Sum of series
2. Display Series
Enter your choice: 1
Sum = -699050.0

Sample output 2

1. Sum of series
2. Display Series
Enter your choice: 2
1 11 111 1111 11111 

Sample output 3

1. Sum of series
2. Display Series
Enter your choice: 3
Invalid choice

Question 7.
Write a program to input integer elements into an array of size 20 and perform the following operations: [15]
i) Display largest number from the array
ii) Display smallest number from the array
iii) Display sum of all the elements of the array

Ans.

import java.util.Scanner;

public class ArrayOperations {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int[] numbers = new int[20];
		System.out.print("Enter 20 numbers: ");
		for (int i = 0; i < 20; i++) {
			numbers[i] = scanner.nextInt();
		}

		int smallest = numbers[0];
		int largest = numbers[0];
		int sum = 0;
		for (int i = 0; i < 20; i++) {
			if (numbers[i] < smallest) {
				smallest = numbers[i];
			}
			if (numbers[i] > largest) {
				largest = numbers[i];
			}
			sum = sum + numbers[i];
		}
		System.out.println("Smallest = " + smallest);
		System.out.println("Largest = " + largest);
		System.out.println("Sum = " + sum);
	}
}

Sample output

Enter 20 numbers: 3 9 1 50 8 5 2 8 6 9 7 5 4 9 7 9 2 67 2 32
Smallest = 1
Largest = 67
Sum = 245

Question 8:
Design a class to overload a function check() as follows:
i) void check(String str, char ch) – to find and print the frequency of a character
in a string.
Example :
Input — Output
Str = “success” number of s present is=3
ch = ‘s’
ii) void check (String s1) – to display only the vowels from string s1 , after converting it to lower case.
Example :
Input:
S1= “computer” output: o u e
Ans.

public class Overload {
	public void check(String str, char ch) {
		int result = 0;
		for (int i = 0; i < str.length(); i++) {
			char currentChar = str.charAt(i);
			if (ch == currentChar) {
				result++;
			}
		}
		System.out.println("number of s present is = " + result);
	}

	public void check(String s1) {
		s1 = s1.toLowerCase();
		for (int i = 0; i < s1.length(); i++) {
			char currentChar = s1.charAt(i);
			if (currentChar == 'a' || currentChar == 'e' || currentChar == 'i' || currentChar == 'o'
					|| currentChar == 'u') {
				System.out.print(currentChar + " " );
			}
		}
	}
}

Question 9:
Write a program to input forty words in an array. Arrange these words in descending order of alphabets, using selection sort technique. Print the sorted array.

Ans.

import java.util.Scanner;

public class SelectionSort {
	public static void main(String[] args) {

		// Accept 40 words

		Scanner scanner = new Scanner(System.in);
		String[] words = new String[40];
		System.out.println("Enter 40 words: ");
		for (int i = 0; i < 40; i++) {
			words[i] = scanner.nextLine();
		}

		// Sort using selection sort

		for (int i = 0; i < words.length - 1; i++) {
			int largestWordIndex = i;
			for (int j = i + 1; j < words.length; j++) {
				if (words[j].compareTo(words[largestWordIndex]) > 0) {
					largestWordIndex = j;
				}
			}
			String temp = words[largestWordIndex];
			words[largestWordIndex] = words[i];
			words[i] = temp;
		}

		// Print sorted array

		for (int i = 0; i < 40; i++) {
			System.out.println(words[i]);
		}
	}
}

10 thoughts on “ICSE Class 10 Computer Applications ( Java ) 2017 Solved Question Paper

  1. Pranav

    In Q6. i.)
    `the for loop is running only for 2 times when the question demands 2 to the and till the power of 20. so basically i think it should be this way for(i=1; i<=20; i++)
    `And (i % 2 == 0)
    this site is very helpful , especially when no are at home and need teachers help.

    Reply
    1. Ranjith Post author

      Yes, it should be i <=20. Corrected it. Thanks for pointing out the error.
      (i % 2 == 1) is correct.

  2. Nidharshanan

    Is this Piglatin program ?
    ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓

    import java.io.*;
    class Piglatin
    {
    public static void main(String args[])throws IOException
    {
    BufferedReader br =new BufferedReader(new InputStreamReader(System.in));
    System.out.print(“Enter any word : “);
    String s=br.readLine();
    String s1,s2,s3;
    s=s.toUpperCase();
    int l=s.length();
    int i;
    char ch;
    for(i=0; i<l; i++)
    {
    ch=s.charAt(i);
    }
    if(ch=='A'||ch=='E'||ch=='I'||ch=='O'||ch=='U')
    {
    break;
    }
    for(i=0; i<l; i++)
    {
    s1=s.charAt(0,i);
    s2=s.charAt(i);
    s3=s2+s1+"AY";
    }
    System.out.println("The piglatin of the word"+s+"is : "+3);
    }
    }

    Reply
    1. Ranjith Post author

      @Garima
      x[3].length()
      x is an array of Strings
      x[3] gives the String at index 3
      length() is a function of String class. So, to get the length of the x[3], it is written as x[3].length()

      May be you are confused between x.length and x[3].length().
      length is a property of an array. So, we simply write x.length to get size of array x.
      But length is a function of String class. So, we write it as .length()

  3. Subrat Nayak

    Hi namaskar I am rakhal from odisha.I want to advice that there is some error in this 2017 paper of computer -application .The error is in question number-3(d) tat inside the for loop the int i=5 should be written as “int i=1″and also the i less than or equal to 5 should be written as i less than 7 or i less than or equal to 6.
    SO I WISH YOU ALL THE BEST OF YOUR LUCK IN ANY EXAMINATIONS

    Reply
    1. Ranjith Post author

      @Subrat Nayak Thanks for pointing out the error.

      I’ve changed the initialization to int i=1.

      The condition i <= 5 is correct. The condition generally doesn’t change when we are converting a for loop to do-while loop. I’ve also verified that both the loops print the same by running the program snippets. May be, you want to verify again…

Leave a Reply

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


*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>