Blog

ICSE Class 10 Computer Applications 2017 Solved Question Paper

ICSE-Computer-Applications--2017-Board-Solved-Paper
ICSE Solved Papers

ICSE Class 10 Computer Applications 2017 Solved Question Paper

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:[2]
i) System.out.println(x[1]);
ii) System.out.println(x[3].length());
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 that means (6 <= 24) , which is 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 = a + 6 that means ( a = 6 + 6 ),  then a is updated to 12
Second iteration:
Condition check: a <= 24 that means (12 <= 24) , which is true
Loop is executed for the second time
Loop execution: a % b = 12 % 4 = 0 = 0 Hence, break is executed
System.out.println(a);  This statement will print 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;  From this statement  ASCII value of ‘F’ i.e. 70 will be assigned to m
m = m + 5 = 70 + 5 = 75
System.out.println(m+ ” ” +ch);  & this statement will print 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&lt;=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.
So the first println method , System.out.println(s.indexOf(‘T’)); will print the index of T, which is 0 (zero)
& second println method will take substring stored from 0 to 7th index & concatenate it with  a String “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″;
By doing this, value of A will concatenate with value of B & further these are concatenated with String “200”
So , D = “26″ + “100″ + “200″ = 26100200
int x= Integer.parseInt(A);
x = Integer.parseInt(“26″) , By doing this String “26” will converted into Integer 26 , and it will be assigned into variable x
int y=Integer.parseInt(B);
y= Integer.parseInt(“100”) , Similarly String “26” will be converted into Integer 26 , and it will be assigned into variable y
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&lt;=4;i++)
{
for(int j=2;j&lt;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 kb = new Scanner(System.in);
		System.out.print("Enter name: ");
		n = kb.next();
		System.out.print("Enter units: ");
		units = kb.nextInt();
	}
	public void calculate() {
		if (units<= 100)
		{
			bill = units * 2;
		}
		else if (units>100 && units<=300)
		{
			bill = units * 3;
		}
		else
		{
			bill = units * 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 EB = new ElectricBill();
		EB.accept();
		EB.calculate();
		EB.print();
	}
}

Sample output

Enter name: Atharv
Enter units: 50
Name of the customer: Atharv
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 kb = new Scanner(System.in);
System.out.print("Enter number: ");
int n = kb.nextInt();
int sum = 0;
int product = 1;
while (n>0) {
int r = n % 10;
sum = sum + r;
product = product * r;
n = n / 10;
}
if (sum == product) {
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: 1254
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 MenuDriven {
	public static void main(String[] args) {
	System.out.println("Press 1 for Sum of series");
	System.out.println("Press 2 for Display Series");
        System.out.print("Enter your choice: ");
	Scanner kb = new Scanner(System.in);
	int choice = kb.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
Press 1 for Sum of series
Press 2 for Display Series
Enter your choice: 1
Sum = -699050.0
Sample output 2
Press 1 for Sum of series
Press 2 for Display Series
Enter your choice: 2
1 11 111 1111 11111
Sample output 3
Press 1 for Sum of series
Press 2 for 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 MyArray {
	public static void main(String[] args) {
		Scanner kb = new Scanner(System.in);
		int[] arr = new int[20];
		System.out.print("Enter 20 numbers in an array: ");
		for (int i = 0; i < 20; i++) {
			arr[i] = kb.nextInt();
		}
		int smallest = arr[0];
		int largest = arr[0];
		int sum = 0;
		for (int i = 0; i < 20; i++) {
			if (arr[i] < smallest)
			{
				smallest = arr[i];
			}
			if (arr[i] > largest)
			{
			largest = arr[i];
			}
			sum = sum + arr[i];
		}
		System.out.println("Smallest = " + smallest);
		System.out.println("Largest = " + largest);
		System.out.println("Sum = " + sum);
	}
}

Sample output
Enter 20 numbers: 1 2 3 4 5 6 7 8 9 8 5 4 2  4 5 6 8 4 7 82
Smallest = 1
Largest = 82
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 kb = new Scanner(System.in);
String[] words = new String[40];
System.out.println("Enter 40 words: ");
for (int i = 0; i < 40; i++) {
words[i] = kb.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]);
}
}
}

Comments (6)

  1. Asim

    sir question 2 e ans is i think wrong because small is 70 but small a starts from 97

    1. User Avatar
      admin

      No Asim , ASCII value of Capital ‘F’ is 70
      Remember :
      Ascii for A-Z is from 65 to 90
      & for a-z is from 97 to 122

      1. Asim

        yes sir i have seen i was bit confused i forgot ht u have stored “F” in ch then u hvave added

        1. User Avatar
          admin

          yeah ? , Hey Asim we’re uploading today’s (ICSE 10th Computer Applications 2019 Solved ) Paper by tomorrow 12 to 2 pm, you will be notified, Please do share with your friends

  2. Hamza

    Thank you sir, it was very helpful
    I also needed a code run through of Q9

  3. User Avatar
    Shubham Tripathi

    Hey Hamza, Selection sort is removed from the syllabus (2020-2021)

Leave your thought here

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

Select the fields to be shown. Others will be hidden. Drag and drop to rearrange the order.
  • Image
  • SKU
  • Rating
  • Price
  • Stock
  • Availability
  • Add to cart
  • Description
  • Content
  • Weight
  • Dimensions
  • Additional information
Click outside to hide the comparison bar
Compare