ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

Max Marks: 80
[2 Hours]

General Instructions

  • Answers to this Paper must be written on the paper provided separately.
  • You will not be allowed to write during the first 15 minutes.
  • This time is to be spent in reading the question paper.
  • The time given at the head of this Paper is the time allowed for writing the answers. O This Paper is divided into two Sections.
  • Attempt all questions from Section A and any four questions from Section B.
  • The intended marks for questions or parts of questions are given in brackets [ ].

SECTION – A [40 Marks]
Attempt All Question

Question 1.
(a) Define encapsulation.
Answer:
Encapsulation is wrapping up of data and its associated functions
into a single unit. It is achieved by the use of access specifiers like 1 public, private, and protected.

(b) What are keywords? Give an example.
Answer:
Keywords are tokens in java that have a specific meaning.
E.g. static

(c) Name any three library packages.
Answer:
java.lang
java.io
java.util

(d) Name the three types of error, syntax, runtime or logical error in the following case below:
(i) Math.sqrt (36 – 45)
(ii) int a;b;c
Answer:
(i) logical
(ii) Syntax

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

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

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

= =operator equals()
It compares two primitive data types It compares two strings

(b) What are the type of casting shown by the following examples:
(i) char c (char) 120;
(ii) int x = ‘t’;
Answer:
(i) Explicit
(ii) Implicit

(c) Differentiate between formal parameter and actual parameter.
Answer:
Formal parameters are used in the function definition using arguments as the input to the function.
Actual parameters are used in calling the above function by passing values.

(d) Write a function prototype of the following:
A function PosChar which takes a string argument and a character argument and returns an integer value.
Answer:
int PosChar(String str, char ch);

(e) Name any two types of access specifiers.
Answer:
private and protected.

Question 3.
(a) Define an impure function.
Answer:
An impure function is a function where the values passed in the formal arguments of function is reflected back in the main function when values are changed by the called function.

(b) Explain the function overloading with example.
Answer:
void lol()
{
String str = “lol”;
‘ }
void lol(int a)
{
String str1 = “lol”;
}

(c) What is default constructor and where is it useful?
Answer:
Default constructor is a constructor without any parameter. It is used to initialize class variables to their default values.

(d) State the difference between selection sort and bubble sort.
Answer:

Selection Sort Bubble Sort
One element is compared with all the elements of the array and position is exchanged at the end of comparison. Adjacent elements of the array are compared and exchanged.

(e) Int i = 5;
if (++5/2 = =0)
System.out.print(“EVEN”);
else
System.out.print(“ODD”);
Answer:
error

(f) Convert the following while loop to the corresponding fir loop:
int m = 5, n =10; while (n>=1)
{
System.out.printIn(m*n); n –;
}
Answer:
50
45
35
30
25
20
15
10
5

(g) Write one difference between primitive data types and composite date types.
Answer:
Primitive data type: Its fundamental data types of java.
Composite data type: It’s a combination of primitive data type.

(h) Analyze the given program segment and answer the following question:
(i) Write the output of the program segment
Answer:
5
10

(ii) How many times does the body of the loop get 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:
3

a. Give the output of the following expression:
a+=a++ + ++a H a + a–; when a=7
Answer:
39

b. Write the return type of the following library
(i) isLetterOrDigit(Char)
(ii) replace(char, char)
Answer:
(i) boolean
(ii) String

SECTION – B (60 Marks)
Attempt any four questions from this Section

The answers in this Section should consist of the Programs in either Blue J environment or any program environment with Java as the base. Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of the program is clearly depicted.

Flow-Charts and Algorithms are not required.

Question 4.
Define a class named BookFair with the following description:
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 of the following criteria

Price Discount
Less than or equal to rs  10000 2% of the price
More than rs 1000 and less than or equal to rs3000 10% of the price
More than rs3000 15% of the 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:

import java.util.*;
class BookFair
{
String Bname;
double price;
BookFair ()
{
Bname = "";
price = 0.0;
}
void input ()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter name and price of the book:");
Bname = sc.nextLine();
price = sc.nextDouble();
}
void display()
{
System.out.printIn(" Name: "+Bname+"\n"+"Price:"+price);
}
void calculate()
{
double discount =0;
if(price <= 1000)
discount = (2.0/100.0)*price;
else if(price >1000 && price <= 3000)
discount = (10.0/100.0)*price;
else if(price >3000)
discount = (15.0/100.0)*price;
else;
price = price - discount;
}
public static void main()
{
BookFair bf = new BookFair();
bf.input();
bf.calculate();
bf.display();
}
}

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

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

import java.util.*;
import java.math.*;
class lol
{
public static void main(String[ ] args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter 1 for number pattern and 2 for string pattern");
int opt = sc.nextIntO;
switch(opt)
{
case 1: int a = 1;
forfint i =1;i<=5;i++)
{
for(int j = 1;j<=i;j++)
{
System.out.print(a+"");
3++;
j
System.out.printInO;
}
break;
case 2 : String str = "ICSE";
for(int i =0;i <str.length();i++)
{
forfint j =0;j<=i; j++)
{
char ch = str.charAt(j);
System.out.print(ch+" ");
}
System.out.printInO;
}
break;
default: System.out.printIn("ERROR");
}// end of switch
}//end of main
}//end of class

Question 6.
Special words are those words which starts and ends with the same letter
Example:
EXISTENCE
COMIC
WINDOW

Palindrome words are those words which read the same from left to right and vice versa
Example:
MALYALAM
MADAM
LEVEL
ROTATOR
CIVIC
All palindromes are special words but all words are not palindromes.
Write a program to accept a word check and print whether the word is a palindrome or only a special word
Answer:

import java.util.*;
class Main
{
public static void main(String [ ]args)
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a word:");
String str = sc.next();
String word ="";
for (int i = str.length()-1;i >=0;i--)
{
char ch = str.charAt(i);
word = word+ch;
}
if(word.equals(str))
System.out.printIn("Palindrome");
else
{
if(str.charAt(0)==str.charAt(str.length()-1))
System.out.printIn("special word");
}
}
}

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

Question 7.
Design a class to overload a function SumSeriesQ as follows:
(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 SumSeriesO – To find and display the sum of the following series:
s = 1+(1*2)+(1*2*3)+………..+(1*2*3*4* n)
Answer:

import java.util .*;
class lol
{
void sumseries(int n, double x)
{
double sum =0;
for(int i =1;i<=n;i++)
{
if(i % 2 == 0)
{
sum = sum -(x/i);
}
else
{
sum = sum + (x/i);
}
}
System.out.printIn("sum = "+sum);
}
void sumseries()
{
long sum = 0;
long product = 1;
for(int i = 1;i <=20;i++)
{
product = product * i;
sum+= product;
}
System.out.printIn("sum = "+sum);
}
}

Question 8.
Write a program to accept a number and check and display whether it is a Niven number or not. (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 lol
{
public static void main(String []args)
{
Scanner sc = new Scanner("System.in");
System.out.printIn("Enter a num:");
int a = sc.nextInt();
int al = a;
int sum =0;
while(a1!=0)
{
int k = a 1 % 10;
sum = sum+ k;
a1/= 10;
}
if(a%sum ==0)
System.out.printIn("Niven number");
else
System.out.printIn("Not Niven number");
}//end of main
}// end of class

ICSE Class 10 Computer Application Sample Question Paper 6 with Answers

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. If found, display the name of the country along with its Wonder, otherwise display “Sorry Not Found!”
Seven wonders – CHICHEN 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.util.*;
class lol
{
public static void main(String args[ ])
{
String wonder[ ]={"CHICHEN ITZA","CHRISTTHE REDEEMER", "TAJMAHAL", "GREATWALL OF CHINA","MACHU PICCHU","PETRA","COLOSSEUM"};
String country} ]={"MEXICO","BRAZIL1,"INDIA","CHINA","PERU","JORDAN","ITALY"};
String str;
int i,len;
Scanner sc=new Scanner(System.in);
System.out.printIn("Enter the name");
str=sc.nextLine();
len=str.length();
boolean flag=false;
for (i=0;i<len;i++)
{
if(str.equalslgnoreCase(country[i]))
{
System.out.printIn(country[i]+""+ wonderfi]);
flag =true;
break;
}
}
if(flag== false)
System.out.printIn("Sorry Not Found");
}//end of main
}//end of class
Variable Data Type Description
discount Double store discount value
opt int Option number
ij int For looping
a int For printing pattern
ch char Reading each character of word.
str String To read word
word String To store reverse word
sum double Store the series of sum
product long Stores product of integers.
a int Read users number
a1 int Modifying the digits
flag boolean To check true or false

ICSE Class 10 Computer Application Question Papers with Answers

Leave a Comment