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

ICSE Class 10 Computer Applications Question Paper 2016 Solved

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

Question 1.
(a) Define Encapsulation.
Answer:
Encapsulation is a process of wrapping code and data together into a single unit. Encapsulation is also known as “Data hiding” because they are protecting data which is prone to change.

(b) What are keywords ? Give an example.
Answer:
In Java, a keyword is a word with a predefined meaning in Java programming language syntax. Keywords are reserved for Java, it may not be used as identifiers for naming variables, classes, methods or other entities. Examples : continue, for, new, switch

ICSE 2016 Computer Applications Question Paper Solved for Class 10

(c) Name any two library packages.
Answer:

  • java.lang
  • java.util

(d) Name the type of error (syntax, runtime or logical error) in each case given below: [2]
(i) Math.sqrt (36 – 45)
(ii) int a;b;c;
Answer:

  • Math.sqrt(36-45); (Syntax error; semicolon required)
  • int a, b, c; (Syntax error; single-line variables to be separated by comma)

(e) If int x [] = { 4, 3, 7, 8, 9, 10}; what are the values of p and q? [2]
(i) p = x. length
(ii) q = x[2] + x[5] * x[1]
Answer:

  • 6
  • q = 7 + 10*3 = 37

Question 2.
(a) State the difference between == operator and equals () method. [2]
Answer:

equals() method = = operator
(i) The equals( ) method is present in the java.lang. Object class and it is expected to check for the equivalence of the state (contents) of objects. (i) The ‘= =’ operator is expected to check that if the objects refer to the same place.
(ii) The equals( ) method compares the values. (ii) = = operator compares the references.

(b) What are the types of casting shown by the following examples: [2]
(i) char c = (char) 120;
(ii) intx= ‘t’;
Answer:

  • char c = (char) 120; This is a narrow conversion and called explicit conversion.
  • int x = ’t ‘; This is a widening conversion and called implicit conversion.

(c) Differentiate between formal parameter and actual parameter. [2]
Answer:

Actual Parameter Formal Parameter
(i) The parameters that appear in the function call statement are   called actual parameters.
e.g.,
x = add(m, n);
Here m and n represent the actual parameters.
(i) The parameters that appear in the function definition are called formal parameters.
e.g.,x = add(int a, int b);
Here a and b represent the formal parameters.
(ii) Actual parameters are used to pass the values. (ii) Formal parameters are used to receive the values.

ICSE 2016 Computer Applications Question Paper Solved for Class 10

(d) Write a Junction prototype of the following: [2]
A function PosChar which takes a string argument and a character argument and returns an integer value.
Answer:

void PosChar(double a, char b) {
System.out.println(“Retum Value : “ + String. valueOf(a));
System.out.println(“Return Value : “ + String.
valueOf((int)b));
}

(e) Name any two types of access specifiers. [2]
Answer:

  • public
  • private

Question 3.
(a) Give the output of the following string functions: [2]
(i) “MISSISSIPPI”. indexOf(‘S )+
“MISSISSIPPI”. lastlndexOff(‘I’)
(ii) “CABLE ”. compareTo(“CADET”)
Answer:
(i) 12
(ii) -2

(b) Give the output of the following Math functions: [2]
(i) Math.ceil(4.2)
(ii) Math.abs(-4)
Answer:
(i) 5.0
(ii) 4

(c) What is a parameterized constructor ? [2]
Answer:
A constructor that have parameters is known as parameterized constructor. Parameterized constructor is used to provide different values to the distinct objects.

(d) Write down java expression for: [2]
T = \(\sqrt{A^2+B^2+C^2}\)
Answer:
double T = Math.sqrt((A*A + B*B + C*C));

(e) Rewrite the following using ternary operator: [2]
if(x%2 == 0)
System. out.print(“E YEN “);
else
System.out.print(“ODD”);
Answer:
String result = (x%2 = 0) ? “EVEN” : “ODD”; System.out.println(result);

ICSE 2016 Computer Applications Question Paper Solved for Class 10

(f) Convert the following while loop to the corresponding for loop: [2]
int m = 5, n = 10;
while (n>=1)
{
System.out.println(m * n);
n- -;
}
Answer:
int m = 5, n;
for (n = 10; n >=1; n- -)
{
System.out.println(m*n);
}

(g) Write one difference between primitive data types and composite data types. [2]
Answer:

  • Primitive data types are built-in data types. Java provides these data types. User-defined data types are created by users.
  • The size of primitive data types are fixed. The size of user-defined data types are variable.
  • Primitive data types are available in all parts of Java programs. The availability of user-defined data types depends upon their scope.

(h) Analyze the given program segment and answer the following questions: [2]
(i) Write the output of the program segment
(ii) How many times does the body of the loop gets executed ?
for (int m = 5; m <= 20; m += 5)
{ if (m%3==0)
break;
else
if (m%5==0)
System.out.println(m);
continue;
}
Answer:
(i) 5
10
(ii) Two times

(i) Give the output of the following expression : [2]
a+= a++ + ++a + –a + a–; when a = 7
Answer:
39

(j) Write the return type of the following library functions: [2]
(i) isLetterOrDigit(char)
(ii) replace(char, char)
Answer:
(i) This method returns true if the character is a letter or digit, false otherwise.
(ii) It returns a string derived from this string by replacing every occurrence of oldChar with newChar.

ICSE 2016 Computer Applications Question Paper Solved for Class 10

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

Question 4.
Define a class named BookFair with the following description: [15]
Instance variables /Data members :
String Bname – stores the name of the book
double price – stores the price of the book Member methods:
(i) BookFair() – Default constructor to initialize data members
(ii) void input() – To input and store the name and the price of the book
(iii) void calculate() – To calculate the price after discount.
Discount is calculated based on the following criteria

Price Discount
Less than or equal to ₹ 1000 2% of price
More than ₹ 1000 and less than or equal to ₹ 3000 10% of price
More than ₹ 3000 15% of price

(iv) void display()- To display the name and price of the book after discount.
Write a main method to create an object of the class and call the above member methods.
Answer:

class BookFair {
private String Bname;
private double price;
void BookFairQ {
Bname = “";
price = 0.0;
}
void input(String bk, double pr) {
Bname = bk;
price = pr;
System.out.println(“Book Name” +Bname);
System.out.println(“Book Price-’ +price);
}
void calculate() {
double discount;
if (price <= 1000)
discount = price*2/100;
System.out.println(“Discounted Price =” +price);
if (price > 1000 && price <= 3000)
discount = price* 10/100;
System.out.println(“Discounted Price =” +price);
if (price > 3000)
discount = price* 15/100;
System.out.println(“Discounted Price=” +price);
}
void display!) {
System.out.println(“Book Name = ” +Bname);
System.out.println(“Price after discount = ” +price);
}
}

ICSE 2016 Computer Applications Question Paper Solved for Class 10

Question 5.
Using the switch statement, write a menu driven program for the following: [15]
(i) To print the Floyd s triangle [Given below]
ICSE 2016 Computer Applications Question Paper Solved for Class 10 1
(ii) To display the following pattern I
ICSE 2016 Computer Applications Question Paper Solved for Class 10 2
For an incorrect option, an appropriate error message should be displayed.
Answer:

import java.io.*;
import java.util.*;
class FloydPattem {
public void main(int choice)throws IOException {
InputStreamReader reader = new InputStream Reader(System.in);
BufferedReader input = new BufferedReader (reader);
System.out.println(“Enter 1. Floyd’s Triangle ”);
System.out.println(“Enter 2. Pattern ”); switch(choice) {
case 1:
int n, num = 1, c, d;
Scanner in = new Scanner(System.in);
System.out.println(“Enter the number of rows of floyd’s triangle you want”);
n = in.nextlnt();
System.out.println(“Floyd’s triangle:-”);
for (c = 1; c <= n; C++) {
for (d = 1; d <= c; d++ ) {
System.out.print(num+” ”);
num++;
}
System.out.println();
}
break;
case 2:
String str;
Scanner pattern = new Scanner (System.in);
System.out.println(“Enter the input”);
str = pattem.next();
int 1 = str.length();
for(int i = 0; i<1; i++) {
foifint j = 0; j <= i; j++)
System.out.print(str.charAt(j));
System.out.println();
}
break;
default:
System.out.println(“Incorrect Choice”);
break;
}
}
}

Question 6.
Special words are those words which starts and ends with the same letter. [15]
Examples:
EXISTENCE
COMIC
WINDOW
Palindrome words are those words which read the same from left to right and vice-versa
Examples:
MALAYALAM
MADAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words, but all special words are not palindromes.
Write a program to accept a word, check and print whether the word is a palindrome or only special word.
Answer:

import java.util.*;
class SpecialPalin {
public static void main(String args[]) {
String word;
Scanner sc = new Scanner(System.in);
System.out.println(“Please type a word: ”);
word = sc.nextLine();
if (word.charAt(O) = word.charAt(word. length()-l)) {
System.out.println(“The word “+word+”
begins and ends with the character
“+word.charAt(0));
}
else {
System.out.println (“The word “+word+”
begins with “+word.charAt(0)+” and
ends with “ + 0(word.length()-l)+”.
Different Characters!”);
String rev = “ ”;
int i;
for(i=word.length()- 1; i >= 0; i—) {
rev = rev + word.charAt(i);
}
if(rev.equalsIgnoreCase(word))
System.out.println(word + “ is a Palindrome.”);
else
System.out.println(word + “ is not a Palindrome.”);
}
}
}

ICSE 2016 Computer Applications Question Paper Solved for Class 10

Question 7.
Design a class to overload a function SumSeriesQ as follows: [15]
(i) void SumSeries(int n, double x) — With one integer argument and one double argument to find and display the sum of the series given below:
s = \(\frac{x}{1}-\frac{x}{2}+\frac{x}{3}-\frac{x}{4}+\frac{x}{5}\) ………… to n terms

(ii) void SumSeries() – To find and display the sum of the following series:
s = 1 + (1 × 2) + (1 × 2 × 3) + …………… + (1 × 2 × 3 × 4 … …. …. × 20)
Answer:
import java.io.*;
class MethodOverloadSeries {
(i) void SumSeries(int n, double x)throws IOException {
System.out.println(“Value of n =”);
System.out.println(“Value of x =”);
double sum = 0;
for (int i = 1; i<=n; i++) {
sum += x/i;
}
System.out.println(+sum);
}

(ii) void SumSeries()throws IOException {
int sum = 0;
int n = 20;
while (n !=0){
int mul = 1;
for(int i=1; i<=n; i++){
mul *= 1 *i;
}
sum = sum + mul;
n–;
}
System.out.println(sum);
}
}

Question 8.
Write a program to accept a number and check and display whether it is a Niven number or not. [15]
(Niven number is that number which is divisible by its sum of digits).
Example:
Consider the number 126.
Sum of its digits is 1+2+6 = 9 and 126 is divisible by 9.
Answer:

import java.util.*;
class NivenNumber {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print(“Enter a number : ”);
int n = sc.nextlnt();
int c = n, d, sum = 0;
//finding sum of digits
while(c > 0) {
d = c%10;
sum = sum + d;
c = c/10;
}
if(n%sum == 0)
System.out.println(n+” is a Niven Number.”);
else
System.out.println(n+” is not a Niven Number.”);
}
}

ICSE 2016 Computer Applications Question Paper Solved for Class 10

Question 9.
Write a program to initialize the seven Wonders of the World along with their locations in two different arrays. Search for a name of the country input by the user. [15]
If found, display the name of the country along with its Wonder, otherwise display “Sorry Not Found!”.
Seven wonders: CHIC HEN ITZA, CHRIST THE REDEEMER, TAJMAHAL, GREAT WALL OF CHINA, MACHU PICCHU, PETRA, COLOSSEUM
Locations: MEXICO, BRAZIL, INDIA, CHINA, PERU, JORDAN, ITALY
Example: Country Name : INDIA
Output: INDIA – TAJMAHAL
Country Name: USA
Output: Sorry Not Found!
Answer:

import java.io.*; class Seven Wonders {
public static void data() throws IOException {
String wonder[ ] = {“CHICHEN ITZA”,“CHRIST THE REDEEMER”,“TAJMAHAL”,“GREAT WALL OF CHINA”,“MACHUPICCHU”, “PETRA”, “COLOSSEUM”};
String location[ ] = {“MEXICO”, “BRAZIL”, “INDIA”, “CHINA”, “PERU”, “JORDAN”, “ITALY”};
boolean value = false;
System.out.println(“Enter country to search”);
BufferedReader reader = new BufFeredReader(new InputStreamReader(System.in));
String a = reader.readLine();
for(int i=0; i<5; i++) {
if(a.compareTo(wonder[i]) == 0) {
value = true;
System.out.println(“Search Successful!”);
System.out.println(“Name is::” +wonder[i]);
}
}
if(value == false) {
System.out.println(“Sorry Not Found!”);
data();
}
}
}