Blog

ICSE Class 10 Computer Applications 2015 Solved Question Paper

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

ICSE Class 10 Computer Applications 2015 Solved Question Paper

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

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

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

SECTION A (40 Marks)

Answer all questions from this Section

 
Question 1.
(a) What are the default values of the primitive datatypes int and float? [2]
Ans. The default value of int is 0 and the default value of float is 0.0f.
(b) Name any two OOP’s principles. [2]
Ans. The OOPs principles are
Encapsulation
Abstraction
Polymorphism
Inheritance
(c) What are identifiers? [2]
Ans. Identifiers are names of variables, classes, packages, methods and packages in a java program.
(d) Identify the literals listed below: [2]
(i) 0.5 (ii)’A’ (iii) false (iv) “a”
Ans. (i) Floating point literal
(ii) Character literal
(iii) Boolean literal
(iv) String literal
(e) Name the wrapper class of char type and boolean type. [2]
Ans. The wrapper class of char type is Character and the wrapper type of boolean type is Boolean.
Question 2
(a) Evaluate the value of n if the value of p=5, q=19 [2]

int n = (q-p) > (p-q) ? (q-p) : (p-q);

Ans.

int n = (19-5) > (5-19) ? (19-5) : (5-19)
int n = 14 > -14 ? 14 : -14
int n = true ? 14 : -14
int n = 14

 
(b) Arrange the following primitive data types in an ascending order of their size: [2]
(i) char (ii) byte (iii) double (iv) int
Ans. The sizes of the given data types are as follows
char = 2 bytes
byte = 1 byte
double = 8 bytes
int = 4 bytes
Arranging them in ascending order gives byte < char < int < double
(c) What is the value stored in variable res given below: [2]
double res = Math.pow(“345”.indexOf(‘5’), 3);
Ans.
double res = Math.pow(“345”.indexOf(‘5’), 3);
= Math.pow(2, 3);
= 8.0
Answer is 8.0 instead of 8 as Math.pow returns a double and not an int.
(d) Name the two types of constructors. [2]
Ans. Default constructor and 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);
}
Ans.
q = 30, b = 50
a = a + b = 20 + 50 = 80
a = 80, b = 50
b = a – b = 80 – 50 = 30
a = 80, b = 30
a = a – b = 80 – 30 = 50
1 = 50, b = 30
System.out.println(a + ” , ” + b) will print
30 , 50
Question 3
(a) State the data type and the value of y after the following is executed : [2]
char x = ‘7’;
y = Character.isLetter(x);
Ans. Data type of y will be boolean and value will be false.
(b) What is the function of catch block in exception handling? Where does it appear in a program? [2]
Ans. catch batch catches the specified exception type and handles the same. It appears between try and finally block. Ex: In the following snippet, if code1 throws an Exception, code 2 will be executed.

try {
// code 1
} catch (Exception e) {
// code 2
} finally {
// code 3
}
(

 
c) State the output of the following program segment is executed: [2]
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.equalsIgnoreCase(h));
Ans.
String a = “Smartphone”, b = “Graphic Art”;
String h = a.substring(2, 5);
= “Smartphone”.substring(2, 5);
= art
String k = b.substring(8).toUpperCase();
= “Graphic Art”.substring(8).toUpperCase();
= Art.tpUpperCase()
= ART
System.out.println(h);
art
System.out.println(k.equalsIgnoreCase(h));
“ART”.equalsIgnoreCase(“art”)
true
The output will be
art
true
(d) The access specifier that gives most accessibility is __________ and the least accessibility is ___________ [2]
Ans. 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]
Ans. (i) Math.sin()
(ii) trim()
(f)
(i)  What will the code print? [2]

int arr[] = new int [5];
System.out.println(arr);

(i) 0 (ii) value stored in arr[0] (iii) 0000 (iv) garbage value
Ans.  Option (iv) garbage value – A random string will be printed. arr is an object. When an object is printed, the .toString() method is invoked which gives the hashcode of the object which will be a random value.
(ii) Name the keyword which is used to resolve the conflict between method parameter and instance variables/fields
Ans. this keyword
Example

public class Main {
private int a = 10;
public void test(int a) {
System.out.println(a); // Will print the value passed to test() method
System.out.println(this.a); // Will print 10
}
}

 
(g) State the package that contains the class : [2]
(i) BufferedReader
(ii) Scanner
Ans. (i) java.io
(ii) java.util
(h) Write the output of the following code segment: [2]

char ch;
int x = 97;
do {
ch = (char) x;
System.out.print(ch + " ");
if (x % 10 == 0)
break;
++x;
} while (x <= 100);

Ans. The do-while loop runs for values of x from 97 to 100 and prints the corresponding char values.
97 is the ASCII value for a, 98 is the ASCII value for 99…
So, the output will be
a b c d
(i) Write the Java expression for: a2+b2 /2ab [2]
Ans. (Math.pow(a, 2) + Math.pow(b, 2)) / (2 * a * b)
(j) If int y = 10 then find int z = (++y * (y++ + 5)); [2]
Ans. Increment operator has the highest precedence. So, ++y and y++ will be evaluated starting from left.
In ++y, the value of y will be incremented to 11 and then 11 will be used in the expression.
When y++ is evaluated, the current value of y i.e. 11 will be used and then y will be incremented from 11 to 12.
int z = (++y * (y++ + 5));
= 11 * (11 + 5 )
= 11 * 16
= 176

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 ParkingLot 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 vno and hours
void calculate() – To compute the parking charge at the rate of Rs.3 for the first hour or part thereof, and Rs.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]
Ans.

import java.util.Scanner;
public class ParkingLot {
private int vno;
private int hours;
private double bill;
public void input() {
Scanner kb = new Scanner(System.in);
System.out.print("Enter vehicle number: ");
vno = kb.nextInt();
System.out.print("Enter hours: ");
hours = kb.nextInt();
}
public void calculate() {
bill = 3 + (hours - 1) * 1.50;
}
public void display() {
System.out.println("Vehicle number: " + vno);
System.out.println("Hours: " + hours);
System.out.println("Bill: Rs. " + bill);
}
public static void main(String[] args) {
ParkingLot parkingLot = new ParkingLot();
parkingLot.input();
parkingLot.calculate();
parkingLot.display();
}
}

 
Sample Output
Enter vehicle number: 34
Enter hours: 4
Vehicle number: 34
Hours: 4
Bill: Rs. 7.5
Question 5
Write two separate programs to generate the following patterns using iteration(loop) statements: [15]
(a)
*
* #
* # *
* # * #
* # * # *
(b)
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
Ans.
(a)

import java.util.Scanner;
public class Pattern1 {
	public static void main(String[] args) {
		Scanner kb = new Scanner(System.in);
		System.out.print("Enter n: ");
		int n = kb.nextInt();
		for (int i = 1; i <= n; i++)
		{
			for (int j = 1; j <= i; j++)
			{
				if (j % n == 1)
				{
					System.out.print("* ");
				}
				else
				{
					System.out.print("# ");
				}
			}
			System.out.println();
		}
	}
}

Sample output:1
Enter n: 5
*
* #
* # *
* # * #
* # * # *
(b)

import java.util.Scanner;
public class Pattern2{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		System.out.print("Enter n: ");
		int n = scanner.nextInt();
		for (int i = n; i >= 1; i--)
		{
			int num = n;
			for (int j = 1; j <= i; j++)
			{
				System.out.print(num + " ");
				num--;
			}
			System.out.println();
		}
	}
}

 
Sample output
Enter n: 5
5 4 3 2 1
5 4 3 2
5 4 3
5 4
5
Question 6
Write a program in to input and store all roll numbers, names and marks in 3 subjects of n number of students in five single dimensional arrays and display the remark based on average marks as given below: [15]
Average marks = total marks/3
AVERAGE MARKS REMARK
85 – 100 EXCELLENT
75 – 84 DISTINCTION
60 – 74 FIRST CLASS
40 – 59 PASS
Less than 40 POOR
Ans.

import java.util.Scanner;
public class Marks {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		System.out.print("Enter number of students: ");
		int n = scanner.nextInt();
		int[] rollNumbers = new int[n];
		String[] names = new String[n];
		int[] subject1Marks = new int[n];
		int[] subject2Marks = new int[n];
		int[] subject3Marks = new int[n];
		for (int i = 0; i < n; i++)
		{
			System.out.println("Student " + (i + 1));
			System.out.print("Enter roll number: ");
			rollNumbers[i] = scanner.nextInt();
			System.out.print("Enter name: ");
			scanner.nextLine(); // To consume the new line produced on hitting
			// enter after entering roll number
			names[i] = scanner.nextLine();
			System.out.print("Enter marks in subject 1: ");
			subject1Marks[i] = scanner.nextInt();
			System.out.print("Enter marks in subject 2: ");
			subject2Marks[i] = scanner.nextInt();
			System.out.print("Enter marks in subject 3: ");
			subject3Marks[i] = scanner.nextInt();
		}
		for(int i = 0; i < n; i++)
		{
			System.out.println("Roll number = " + rollNumbers[i] + ", Name = " + names[i]);
			int averageMarks = (subject1Marks[i] + subject2Marks[i] + subject3Marks[i]) / 3;
			if (averageMarks >= 85 && averageMarks <= 100)
			{
				System.out.println("EXCELLENT");
			}
			else if(averageMarks >= 75 && averageMarks <= 84)
			{
				System.out.println("DISTINCTION");
			}
			else if (averageMarks >= 60 && averageMarks <= 74)
			{
				System.out.println("FIRST CLASS");
			}
			else if (averageMarks >= 40 && averageMarks <= 59)
			{
				System.out.println("PASS");
			}
			else if (averageMarks < 40)
			{
				System.out.println("POOR");
			}
		}
	}
}

Sample output

Enter number of students: 2
Student 1
Enter roll number: 1
Enter name: Kittu
Enter marks in subject 1: 90
Enter marks in subject 2: 100
Enter marks in subject 3: 95
Student 2
Enter roll number: 2
Enter name: Bittu
Enter marks in subject 1: 90
Enter marks in subject 2: 85
Enter marks in subject 3: 100
Roll number = 1, Name = Kittu
EXCELLENT
Roll number = 2, Name = Bittu
EXCELLENT

Question 7
Design a class to overload a function Joystring() as follows: [15]
(i) void Joystring(String s, char ch1, char ch2) with one string and two character arguments that replaces the character argument ch1 with the character argument ch2 in the given string s and prints the new string
Example:
Input value of s = “TECHNALAGY”
ch1 = ‘A’
ch2 = ‘O’
Output : “TECHNOLOGY”
(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”
First Index : 5
Last Index : 36
(iii) void Joystring(String s1, String s2) with two string arguments that combines the two strings with a space between them and prints the resultant string
Example :
Input value of s1 = “COMMON WEALTH”
s2 = “GAMES”
Output : “COMMON WEALTH GAMES”
(use library functions)
Ans.

import java.util.Scanner;
public class StringOperations {
	public void Joystring(String s, char ch1, char ch2) {
		String output = s.replace(ch1, ch2);
		System.out.println("Output = " + output);
	}
	public void Joystring(String s) {
		int firstIndexOfSpace = s.indexOf(' ');
		int lastIndexOfSpace = s.lastIndexOf(' ');
		System.out.println("First index of space = " + firstIndexOfSpace);
		System.out.println("Last index of space = " + lastIndexOfSpace);
	}
	public void Joystring(String s1, String s2) {
		String output = s1.concat(" ").concat(s2);
		System.out.println("Output = " + output);
	}
	public static void main(String[] args) {
		Scanner kb = new Scanner(System.in);
		StringOperations stringOperations = new StringOperations();
		// Joystring method 1
		System.out.print("Enter string: ");
		String s1 = kb.nextLine();
		System.out.print("Enter ch1: ");
		char ch1 = kb.nextLine().charAt(0);
		System.out.print("Enter ch2: ");
		char ch2 = (char) kb.nextLine().charAt(0);
		stringOperations.Joystring(s1, ch1, ch2);
		// Joystring method 2
		System.out.print("Enter string: ");
		String s2 = kb.nextLine();
		stringOperations.Joystring(s2);
		// Joystring method 3
		System.out.print("Enter s1: ");
		String s3 = kb.nextLine();
		System.out.print("Enter s2: ");
		String s4 = kb.nextLine();
		stringOperations.Joystring(s3, s4);
	}
}

 
Sample output

Enter string: TECHNALAGY
Enter ch1: A
Enter ch2: O
Output = TECHNOLOGY
Enter string: Cloud computing means Internet based computing
First index of space = 5
Last index of space = 36
Enter s1: COMMON WEALTH
Enter s2: GAMES
Output = COMMON WEALTH GAMES

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]
Ans.

import java.util.Scanner;
public class SortNames {
public static void main(String[] args) {
Scanner kb = new Scanner(System.in);
String[] names = new String[20];
// Accept names
System.out.println("Enter 20 names");
for (int i = 0; i < 20; i++) {
names[i] = kb.nextLine();
}
// Sort names using bubble sort
for (int i = 0; i < names.length; i++)
{
	for (int j = 1; j < (names.length - i); j++)
	{
		if (names[j - 1].compareTo(names[j]) > 0)
		{
			String temp = names[j - 1];
			names[j - 1] = names[j];
			names[j] = temp;
		}
	}
}
// Print names
System.out.println("Sorted names: ");
for (int i = 0; i < names.length; i++)
{
	System.out.println(names[i]);
}
}
}

Sample output
Enter 20 names
Ram
Arjun
Tarun
Karthik
Sweety
Shalini
Priya
Archana
Shweta
Shiva
Sita
Krishna
Savitri
Hema
Siddharth
Nani
Sachin
Kittu
Bittu
Akhil
Sorted names:
Akhil
Archana
Arjun
Bittu
Hema
Karthik
Kittu
Krishna
Nani
Priya
Ram
Sachin
Savitri
Shalini
Shiva
Shweta
Siddharth
Sita
Sweety
Tarun
Question 9
Use switch statement,write a menu driven program to: [15]
(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 : 120.
For an incorrect choice, an appropriate error message should be displayed.
Ans.

import java.util.Scanner;
public class Menu {
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		System.out.println("1. Factors");
		System.out.println("2. Factorial");
		System.out.print("Enter your choice: ");
		int choice = scanner.nextInt();
		switch (choice)
		{
			case 1:
				System.out.print("Enter n: ");
				int n = scanner.nextInt();
				for (int i = 1; i < n; i++)
				{
					if (n % i == 0)
					{
						System.out.println(i);
					}
				}
				break;
			case 2:
				System.out.print("Enter n: ");
				n = scanner.nextInt();
				int factorial = 1;
				for (int i = 1; i <= n; i++)
				{
					factorial = factorial * i;
				}
				System.out.println("Factorial: " + factorial);
				break;
			default:
				System.out.println("Invalid choice");
				break;
		}
	}
}

 
Sample output 1
1. Factors
2. Factorial
Enter your choice: 1
Enter n: 15
1
3
5
Sample output 2
1. Factors
2. Factorial
Enter your choice: 2
Enter n: 5
Factorial: 120
Sample output 3
1. Factors
2. Factorial
Enter your choice: 3
Invalid choice

Comments (2)

  1. Anshuman

    Can you help me with programming iam not able to understand

  2. User Avatar
    Shubham Tripathi

    In which question u’re facing difficulty ??

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