ICSE Board Guess Paper – 2010
Subject – Computer Application
[Set-1]
SECTION-A
Q1. i) Write any two rules for naming variable.
ii) Define encapsulation.
iii) What are different access modifiers? Write two modifiers which have holes in their scope?
iv) State the difference between while and do-while statement.
v) State the difference between constructor and function (method). (2x5=10)
Q2. i) Read the following program and answer the given questions : 5
class demo{
public void main( ) {
int a,b,i,j;
for(i=1;i<5;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 program ? (3)
ii) Write True / False for the following statements : (5)
1. && is relational operator.
2. Float stores 4 bytes of data
3. character is used for new line
4. The keywords are reserve words.
Java is of dual utility.
Q3. i) Explain the function of the following with its syntax and an example :
-
- do -while
- switch statement
ii) Differentiate between equals() and equalsIgnorecase()
iii) What is the difference between syntax error and logical error.
iv) What is the value of (1/1.0)-(1/-1.0)
v) Convert the following segment into equivalent for loop
{
I=0;
while ( i<=20)
System.out.print( i+" ");
I++;
} (2x5=10)
Q4. I) What do you understand by prefix and postfix operators? Give example. 2
ii) Give the output of the following. 4
char ch=’A’;
int x = 32, y = 2;
i) System.out.println(ch+y);
ii) System.out.println(ch+x);
iii) System.out.println(++ch);
iv) System.out.println((char)(ch+x+y));
iii) What do you mean by Object. 2
iv) Find the value of z in the following program segment. 2
int x = 5, y = 12, z;
z = (x>= y ? x – y : y – x );
SECTION-B
Q5. Define a class Stock having the following description: 15
Data members are name, quantity, rate Member functions are
i) public void input( ) [To input name, quantity and rate]
ii) public void sell(int x) [reduce x quantity from stock after checking stock]
iii) public void add(int y) [ add y quantity into stock]
v) public void display( ) [display current stock position]
Q6. Write a menu driven program to accept a number from the user and do the following? 15
a) Test for palindrome no. (by reversing the digits the no. does not change e.g. 121)
b) Find the average of the digits?
c) Find the sum of first and last digit?
Q7. Write a function pascals to create a pascal's triangle Here the nth line starts with a 1 and is followed by the sum of pairs in the (n-1)th line. Assume there is a 0 at the previous line. The first 4 lines look like following :- 15
1
11
121
1331
14641
Q8. i) Write a class to enter a number and check whether it is palindrome or not 8
ii) Write a class to demonstrate if-else-if statement 7