Read the questions as text
ICSE Class 10 Sample Paper 1
Standard: X
Subject: Computer
Max Marks: 100
Max. Time 2 hours
__________________________________________________________________
This paper is divided into two sections. You are to answer all the questions from section A, and any four from section B.
Section A(40 marks)
Attempt all questions
Question 1. a) What is the purpose of this keyword? b) Write an expression in Java for
C=A5 + sin B c) What are library classes? Give an example. d) What is an exception? Name 2 exception handling blocks. e) What is a constructor and what is its use?
[2X5=10]
Question 2.
[2X5=10]
a) Write a java statement to check if the fourth element of an array arr[10] is divisible
by 2.
b) State the output when number=123 and also state what the method is doing?
void main(int number)
{
int a, b=number, c=0, d, s=0;
while (b!=0)
{
d=b%10;
a=(int)Math.pow(10,c++);
System.out.println(d*a);
b=b/10;
} } c) Differentiate between Binary Search and Linear Search
d) Name the search or sort algorithm that:
i) Makes several passes through the array, selecting the next smallest item in the
array each time and placing it where it belongs in the array.
ii) At each stage, compares the sought key value with the key value of the
middleelement of the array.
e) What do you understand by bitwise operator? Give example.
Question 3. a) Differentiate between Instance variable and Local variable. b) What are the final values stored in x and y below?
double a= -46.55;
double b= 15.94;
double x=Math.abs(Math.floor(a));
[2X5=10]
double y=Math.rint(Math.min(a,b));
c)String s = “Mechanical”; int p = s.indexOf(‘h’);
System.out.println(p);
System.out.println(p+s);
d)State the total size in bytes, of the arrays a[8] of int data type and p[2] of float datatype.
e) Name 2 OOP’s principles
Question 4.
[2X5=10]
a)What is the result stored in x, after evaluating the following expression int x=3; x=++x + 3 * x--
b)Write the difference between length and .length() function.
c) Differentiate between user defined and primitive data type
d) If intn[ ] = { 6,4,3,2,7,9,15,19}, what are the values of x and y? x = Math.pow(n[4], n[2]); y= Math.sqrt(n[5]+n[7]);
e) What is the difference between public and private access modifier.
Section B (60 marks)
Attempt any 4 questions from this section Each program should be written using a variable list so that the logic of the program is clearly depicted.
Question 5.
[15]
Write two separate programs to generate the following patterns using iteration(loop)statements:
a)
b)
&
54321
&#
5432
&#&
543
&#&#
54
&#&#&
5
Question 6. A company has employees, who are divided into four grades depending on their
Basic pay per month as follows,
Basic(Rs./month) Grade
DA HRA
10,001 or more
1
5,001 to 10,000 2
2001 to 5,000
3
2,000 or less
4
40% 40% 30% 30%
30% 25% 20% 15%
If the Net salary which is the total of Basic, DA, and HRA, is above Rs.50, 000 per month then Income Tax at the rate of 30% of the annual salary exceeding 50,000 is deducted on monthly basis.
Taking name of the employee and the Basic (monthly) pay as inputs, prepare & print a pay slip, which contains Name, Grade, Basic monthly pay, DA, HRA, Monthly Income Tax and Net Monthly Salary, for employee.
[15]
Question 7. Write a program to perform linear search on a list of integers given below, to search for an element input by the user, if it is found display the element along with its position, otherwise display the message “Search element not found” 5, 7,9,11,15,20,30,45,89,97
[15]
Question 8. Write a program to input a number and print whether the number is a special number
or not. (A number is said to be a special number, if the sum of the factorial of the
digits of the number is same as the original number).
Example: 145 is a special number, because 1! + 4! + 5! = 1 + 24 + 120 =145
(where ! stands for the factorial of the number and the factorial value of a number is
the product of all integers from 1 to that number, example 5! = 1*2*3*4*5 = 120).
[15]
Question 9. Using the switch statement, write a menu driven program to : i) Generate and display the first 10 terms of the Fibonacci series 0,1,1,2,3,5….The
first two Fibonacci numbers are 0 and 1, and each subsequent number is the sum of the previous two.
ii) Find the sum of the digits of an integer that is input.
Sample Input :
15390
Sample Output:
Sum of the digits = 18
For an incorrect choice, an appropriate error message should be displayed.
[15]
Question 10.
Write a program that encodes a word into Piglatin. To translate word into piglatin
word, convert the word into uppercase and then place the first vowel of the original
word as the start of the new word along with the remaining alphabets. The alphabets
present before the vowel ebing shifted towards the end followed by “AY”.
Sample Input (1) :
London,
Sample Output (1) : ONDONLAY
Sample Input (2) :
Olympics,
Sample Output (1) : OLYMPICSAY
[15]
――――――――――
ICSE Class 10 Sample Paper 2
Standard: X
Subject: Computer
Max Marks: 100
Max. Time 2 hours
__________________________________________________________________
This paper is divided into two sections. You are to answer all the questions from section A, and any four from section B.
Section A(40 marks)
Attempt all questions
Question 1.
[2X5=10]
a) Differentiate between call by value or pass by value and call be reference or pass
by reference.
b)Write an expression in Java for
5x3 + 2y
z = ------------------
x+y
c) What are library classes? Give an example.
d) What is an exception? Name 2 exception handling blocks.
e) Find the errors in the given program segment and rewrite the statements correctly
to assign values to an integer array:-
int a= new int(5);
for(int i=0;i<=5;i++) a[i]=i;
Question 2.
[2X5=10]
a) Operators with higher precedence are evaluated before operators with relatively
lower precedence. Arrange the operators given below in order of higher precedence
to lower precedence.
i) &&
ii) %
iii) >=
iv) ++
b) What is a constructor? When is it invoked?
c) Complete the code below to create an object of Scanner class. Scanner sc= ________ Scanner( ________________)
d) Name the search or sort algorithm that: i) Makes several passes through the array, selecting the next smallest item in the array each time and placing it where it belongs in the array. ii) At each stage, compares the sought key value with the key value of the middle element of the array.
e) State the output of the following program segment. String s= "Examination"; int n= s.length(); System.out.println(s.startsWith(s.substring(5,n))); System.out.println(s.charAt(2)== s.charAt(6));
Question 3.
[2X5=10]
a) List the variables from those given below that are composite data types. i) Static int x;
ii) arr[i]=10; iii) obj.display(); iv) Boolean b; v) private char chr; vi) String str;
b) What are the final values stored in x and y below? double a= -6.35; double b= 14.74; double x=Math.abs(Math.ceil(a)); double y=Math.rint(Math.max(a,b));
c) Rewrite the following program segment using while instead of for statement. int f=1,i;
for(i=1;i<=5;i++) { f*=i; System.out.println(f); }
d) State the total size in bytes, of the arrays a[4] of char data type and p[4] of float data type.
e) What is the difference between / and % operator?
Question 4.
[2X5=10]
a) What is the result stored in x, after evaluating the following expression int x=5; x=x++ * 2 + 3 * --x
b) Write the difference between length and .length() function.
c) Analyse the following program segment and determine how many times the loop will be executed and what will be the output of the program segment.
int k=1,i=2; while(++i<6) k*=i; System.out.println(k);
d) If int n[ ] = { 1,2,3,5,7,9,13,16}, what are the values of x and y? x = Math.pow(n[4], n[2]); y= Math.sqrt(n[5]+n[7]);
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.
Section B Attempt any 4 questions from this section
Each program should be written using a variable list so that the logic of the program is clearly depicted.
Question 5.
Design a class to overload a function series( ) as follows :
i) double series(double n) with one double argument and returns the sum of the
series,
sum= 1/1 + 1/2 +1/3 + …. 1/n
ii) double series(double a, double n) with 2 double arguments and returns the sum of
theseries, sum = 1/a2 + 4/a5 + 7/a8 + 10/a11+…… to n terms
[15 ]
Question 6.
Write a program to assign a full path and file name as given below. Using library
functions, extract and output the file path, file name and file extension separately as
shown.
Input C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg
[15]
Question 7. Write a program to input and store the weight of ten people. Sort and display them in ascending order using the selection sort technique.
[15]
Question 8. Using the switch write a menu driven program to : i) To find and display all the factors of a number input by the user (including 1 and excluding the 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 : 5!=1x2x3x4x5=120 For an incorrect choice an appropriate error message should be displayed.
[15]
Question 9. Define a class called Library with the following descriptions. Instance variables/Data members:
Intacc_num stores the accession number of the book. String title stores the title of the book. String author stores the name of the author Member methods: i) void input() to input and store the accession number, title and author.
ii) void compute() to accept the number of days late, calculate and display the
fine charged at the rate of Rs.2/- per day.
iii) void display() to display the details in the following format.
Accession Number
Title
Author
Write a main method to create an object of the class and call the above member
methods.
[ 15 ]
Question 10. The International Standard Book Number (ISBN) is a unique numeric book identifier which is printed on every book. The ISBN is based upon a 10 digit code. The ISBN is legal if : 1 x digit1 + 2 x digit2 + 3 x digit4 + 4 x digit4 + 5 x digit5 + 6 x digit6 + 7 x digit7 + 8 x digit8 + 9 x digit9 +10 x digit10 is divisible by 11. Example: For an ISBN 1401601499 Sum = 1 x 1 + 2 x 4 + 3 x 0 + 4 x 1 + 5 x 6+ 6 x 0+ 7 x 1+ 8 x 4 + 9 x 9 + 10 x 9 = 253 which is divisible by11. Write a program to :
i) Input the ISBN code as a 10 – digit integer. ii) If the ISBN is not a 10 digit integer, output the message, “Illegal ISBN” and terminate the program. iii) If the number is 10-digit, extract the digits of the number and compute the sum as explained above. If the sum is divisible by 11, output the message, “Legal ISBN”. If the sum is not divisible by 11, output the message, “Illegal ISBN”.
[15]
――――――――――
ICSE Class 10 Sample Paper 3
Standard: X
Subject: Computer
Max Marks: 100
Max. Time 2 hours
__________________________________________________________________
This paper is divided into two sections. You are to answer all the questions from section A,
and any four from section B.
Section A (40 marks)
1.
a. Give one example each of a primitive data type and a composite data type. [2]
b. Complete the code below to create an object of Scanner class.
[2]
Scanner sc= ________ Scanner( ________________)
c. Create a class with one integer instance variable. Initialize the variable using : [2]
i) Default constructor ii) Parameterized constructor
d. Write an expression in java for a3-y5
[2]
e. What is the use of default in a switch?
[2]
2.
a. Write a main difference between while loop & do while loop
[2]
b. Write the output of the following code.
[1]
String str=”Application”;
System.out.println(str.charAt(4));
c. Write the output of the following.
[4]
String s1 = “MINORITY”;
String s2 = “REPORT”;
i. System.out.println(s1.substring(0,3).concat(s2.substring(3,5))
ii. System.out.println(s2.substring(2));
iii. System.out.println(s1.charAt(s1.indexOf(‘R’) + s2.indexOf(‘R’)));
iv. System.out.println(s2.replace(‘p’ , ‘s’));
d. Give an example of Relational operator and a Bitwise Operator.
[1]
e. Differentiate between equals() and compareTo() functions.
[2]
3.
a. Name any two jump statements and their use.
[2]
b. What is a constructor? What is its use?
[2]
c. State the purpose and return data type of the following String functions :-
[2]
i) trim()
ii) charAt( )
d. What is the value stored in variable val given below:
[2]
double val= Math.pow(“345”.indexOf(‘5’),3);
e. What are the values of a and b after the following function is executed, if the values
passed are 39 and 20:
[2]
void paws(int a, int b)
{ a=a+b; b=a-b; a=a-b; System.out.println(a+”,”+b); } 4. a. Analyse the following program segment and determine how many times the loop
will be executed and what will be the output of the program segment.
[2]
int k=1,i=2;
while(++i<6)
k*=i;
System.out.println(k);
b. If int y=10 then find int z=(++y * (y++ + 5));
[2]
c. Differentiate between isUpperCase(char) and toLowerCase(char)
[2]
d. State the output of the following program s egment:
String str1=”great”;
String str2=”minds”;
System.out.println(str1.substring(0,2).concat(str2.substring(1)));
System.out.println(“WH”+(str1.substring(2).toUpperCase())));
[2]
e. Write a statement to create an object of a class Student that invokes a parameterized
constructor that accepts one String and one int type values.
[2]
Section B (60 marks) Attempt any 4 questions out of 6
5. Write a program in Java to accept a line of text from the user and create a new word formed
out of the first letter of each word.
E.g. Mangoes Are Delivered After Midnight
Output: MADAM
[15]
6. Write a program to generate the following pattern
[15]
a) B Bl Blu Blue Bluej
b) 1 12 123 1234 12345
7. Write a program in java to accept a string and find
[15]
a. number of blank spaces in the string
b. number of words in the string
c. number of consonants present in the string
d. number of vowels present in the string
8. Write a class in java to enter any number and print if it is a perfect number.[Hint: a number
is said to be perfect if it is equal to sum of all its factors ex, 6=1+2+3, hence 6 is perfect
number]
[15]
9. a. Using switch case create class which take day number 1-7 & prints the corresponding
day in words [3- Wednesday, 5- Friday]
[7]
b. Write a class to input a number and print if it is a prime number or not.
[8]
10. Define a class named movieMagic with the following description: Instance variables/data members:
int year
–
String title –
float rating –
to store the year of release of a movie to store the title of the movie. to store the popularity rating of the movie. (minimum rating = 0.0 and maximum rating = 5.0)
Member Methods:
(i) movieMagic()
(ii) void accept() (iii) void display()
Default constructor to initialize numeric data members to 0 and String data member to “”. To input and store year, title and rating. To display the title of a movie and a message based on the rating as per the table below.
Rating
Message to be displayed
0.0 to 2.0
Flop
2.1 to 3.4
Semi-hit
3.5 to 4.5
Hit
4.6 to 5.0
Super Hit
Write a main method to create an object of the class and call the above member methods. [15]
――――――――――
ICSE Class 10 Sample Paper 4
Standard: X
Subject: Computer
Max Marks: 100
Max. Time 2 hours
__________________________________________________________________
This paper is divided into two sections. You are to answer all the questions from section A, and any four from section B.
Section A (40 marks)
1.
a. Write an expression in java for cosx+√ a3+b3
[2]
b. What is the difference between if ...else...if ladder and Switch....case.
[2]
c. What is the use of default in a switch?
[2]
d. What is an infinite loop? Write an infinite loop statement.
[2]
e. Name the looping statement most commonly used when the no. of iteration is
fixed and known before setting up the loop.
[2]
2.
a. Write a main difference between while loop & do while loop
[2]
b. Write the output of the following code.
[1]
String str=”COMPUTER”;
System.out.println(str.charAt(2));
c. Write the output of the following code.
[2]
Sting str1=”cat”;
String str2=”cat”;
1. str1==str2;
2. str1.equals(str2);
d. Read the following program and answer the questions
class program{
public void main(){
int a, b , i, j;
for(i=1;i<4;i=i+1){
for(j=1;j<=i; j=j+1){
System.out.print(“”+j);
}
System.out.println();
}}}
I. how many times the first loop of “i” will perform?
[1]
II. how many times the first print statement work?
[1]
III. what will be the output of the program?
[3]
3.
a. Rewrite the following set of if-else statements in terms of switch case statements. [2]
class Demo
{
public void main()
{
int num, calc;
System.out.println(“Enter a number”);
if(num==15)
{
calc=num*25-20;
System.out.println(num+calc);
}
else
if(num==20)
{
calc=num*25-15;
System.out.println(calc-num);
}
}
}
b. Rewrite the following using if....else
[2]
double comm=(sale>2000)?sale*5/100 : 25;
c. Explain the relationship between class and objects.
[2]
d. Explain any two types of access specifiers.
[2]
e. In which package are the wrapper classes contained?
[2]
4.
a. Write the difference between actual and formal parameters.
[2]
b. What is an identifier in java?
[2]
c. Differentiate between isUpperCase(char) and isLowerCase(char)
[2]
d. Write a statement to create an object of a class Rectangle that invokes a parameterized
constructor that accepts two int type values.
[2]
e. Explain Encapsulation.
[2]
Section B(60 marks)
Attempt any 4 questions out of 6
5. Write a program in java to accept a string and find
[15]
a. number of blank spaces in the string
b. number of words in the string
c. number of characters present in the string
6. Write a program to print these series.
a. 1
[7]
22
333
4444
55555
b. 1
[8]
23
456
7 8 9 10
11 12 13 14 15
7. A factory has different categories of workers as given below, who are paid different hourly
rates(R). Wages are determined after accepting the number of hours (H) he works during the
week. The different classes are paid as follows.
[15]
Category
Hourly Rate
Unskilled
Rs. 20.00
Semi-skilled
Rs. 30.00
Skilled
Rs. 40.00
Write a program in java (Create a class) which takes in the category of the worker, his name and the number of hours that he works during the week and displays his name and weekly wages.
8. Write a class in java to enter any number and print if it is a perfect number.[Hint: a number
is said to be perfect if it is equal to sum of all its factors ex, 6=1+2+3, hence 6 is perfect
number]
[15]
9. Write a program to accept a string. Convert the string to uppercase. Count and output the number of double letter sequences that exist in the string.
Sample Input: Aarti bought a cotton shirt and butter from mall
output: 4
[15]
10. Write a manu driven program to perform the following(use switch case statement)
a. S=1/2 + 3/4 - 5/6 + 7/8-------19/20
[7]
b. To print the series 0, 3, 8, 15, 24,......n terms(value of n is to be an input by the
user)
[8]