ICSE sample paper 2021 Computer applications
This paper is divided into two sections. You are to answer all the questions from section A, and any four from section B.
JAVA videos

ICSE sample paper 2021 computer applications
SECTION A (40 Marks)
Attempt all questions
Q A. [5X2=10]
- What is meant by private visibility of a data member?
- Predict the output of the following code
(i)System.out.println((-2>66));
(ii) int a =12, b=14;
System.out.println((++a>9)||(b++<++b));
- Name the following
(i)Java statement to terminate the running java virtual machine
(ii)User defined data type created with certain properties and functions. - classify the following function invocation statements as call by value and call by reference.
(i)add(int a, int b) where int a=5;
(ii)add(int a[]) where int a[]={4,5,3,22}; - State the output of the following code if the input value of x is (i) 10 (ii)11
if(x++==11)
System.out.println(“Result is 11”);
else if(++x==10)
System.out.println(“Result is 10”);
else if(–x==10)
System.out.println(“Result is 10”);
else
System.out.println(“Result is neither 10 nor 11”);
Q B. [5X2=10]
- Write a prototype of a function equal which accepts two Strings and returns a boolean.
- What are wrapper classes? Write two examples of wrapper classes.
- For the method, int add(int a, float b){…..}
identify the return type and the function signature. - State the output of the following program segment.
String S=”Program”;
int n=s.length();
System.out.println(S.endswith(S.substring(4,n));
System.out.println(S.charAt(2)==S.charAt(5));
- String L[]={“How”, “Are” , “You”};
for(int i=0;i<L.length;i++)
System.out.println(L[i].charAt[0]);
Q C. [10X2=20]
- Give one difference between autoboxing and unboxing.
- If a function has several return statements how many of them will be executed?Which one? Why?
- What are the two ways of invoking a function?
- Name the keyword that :
(i) is used to allocate the memory to an array.
(ii) causes the control to transfer back to the method call. - If int x[]={4,3,7,8,9,10};What will be the values of A and B?
A=x.length;
B=x[3]+x[1]*x[2]
- Consider the following code and answer the questions that follow.
class Student
{
int age;
String name;
public static void main()
{
int a, b;
Student Ajay= new Student();
System.out.println(“Object created”);
}
}
(i) What is the name of the object of class student?
(ii) What are the class variables?
(iii) What are the local variables?
(iv)What will be the output of the code?
- Write an expression in java for the following
- Give the output of the following.
System.out.println(“PANDEMIC.toLowerCase());
System.out.println(“TRANSPLANT”.compareTo(“TRANSITION “));
- Convert the following while loop to the corresponding for loop.
int m=5, n=10;
while(n>=1)
{
System.out.print(m*n + “ “ );
n–;
}
- What will be the output of the following
Math.pow(Math.ceil(4.3)+Math.floor(6.4),2);
Math.abs(-4.0)+Math.abs(2.2);
ICSE sample paper 2021 computer applications
SECTION B (60 Marks)
Attempt any four questions from this Section.
Q 4 [15]
Design a class Bicycle with the following description.
Instance variables/data members:
String name – to store the name of customer
long mno – to store the mobile no. of the customer
int days – to store the number of days the customer has taken the bicycle on rent
int bill- to store the bill amount
Member methods:
Bicycle()- parameterized constructor to enter the values
void calculate()- to calculate the bill amount.
No of days Bill (Rs/day)
Days<=7 Rs 200
7<days<=14 Rs 300
14<days<=21 Rs 400
days>21 Rs 500
void display()- to display the details of the customer like name, mobile no, no of days and bill amount. Write the main method to create an object of class and call the above member methods.
Q 5. Write a program to generate the following patterns [15]
a) P P R P R O P R O G P R O G R P R O G R A P R O G R A M | b) * * * * * # # # # * * * # # * |
Q 6. [15]
Write a menu driven program to find the sum of the following series depending on the user choosing 1 or 2
1. S=1/4+1/8+1/12………upto n terms
2. S=1/1!-2/2!+3/3!…….upto n terms
where ! stands for factorial of the number and the factorial value of a number is the product of all integers from 1 to that number, e.g. 5! = 1 2 3 4 5. (use switch-case).
Question 7. [15]
WAP to accept a sentence. Print all the words that start with a vowel and end with a consonant. For example:
Input :”the purpose of education is to replace an empty mind with an open one”
Output: of
education
is
empty
an
open
one
ICSE sample paper 2021 computer applications
Question 8. [15]
Write a program to input ten integers in an anay, Using switch-case- statement perform the appropriate operation as per the choice selected by user from the following menu:
1. Print the factorial of each number from the array
2. Print the sum of only odd numbers from the array
For incorrect choice number, appropriate error message should be displayed
Question 9. [15]
Define a class to overload a function sum() as follows:
- int sum(int a, int b): With two integer variables (a and b)calculate and return the sum of all the even numbers in the range between a and b.Sample input: a=2 and b=12
Output: sum=2+4+6+8+10+12=42
- double sum(double n): With one double argument calculate and return the product of the following series:sum=1.0+2.0+3.0+4.0+……….+n
- int sum(int n): With one integer as an argument and return the product of only the odd digits in the number. Sample input: n=32541
Output: product=3*5*1=15
ICSE sample paper 2021 computer applications