Home > ICSE_Computer Applications, Previous Yr Papers > ICSE Question Paper – 2012 (Solved)

ICSE Question Paper – 2012 (Solved)

ICSE Question Paper – 2012 (Solved)

Computer Applications

Class X

(Time: Two Hours)


SECTION A (40 Marks)

Answer all questions from this Section

Question 1.

(a)Give one example of a primitive data type and composite data type.      [2]

Ans.   Primitive type:  byte/short/int/long/float/double/char/boolean

Composite type: classes/interface/arrays

(b) Give one point of difference between unary and binary operators.  [2]

Ans.  Unary operators work on a single operand eg. ++a  while binary operators work on two operands eg. a+b

© Differentiate between call by value or pass by value and call by reference or pass by reference [2]

Ans. Call by value method creates a new copy of formal parameters and the changes made to them in the called function are not reflected on the actual arguments in the calling function. They work for primitive data types while call by reference method does not create a new copy rather works on the reference of actual arguments and changes made to them in the called function are reflected in the calling function. They work for reference data types.

(d) Write java expression for √2as+u2        [2]

Ans.   double  d= Math.sqrt((2*a*s + u*u));

(e) Name the type of error (syntax, runtime or logical error) in each case given below:       [2]

Ans.  (i) Division by a variable that contains a value of zero :  Runtime error

(ii) Multiplication operator used when the operation should be division : Logical error

(iii) Missing semicolon:  Syntax error

Question 2.

(a) Create a class with one integer instance variable. Initialize the variable using :

(i) Default constructor

(ii) parameterized constructor


class Initialize


int x;  //instance variable

Initialize() //default constructor




Initialize(int a) //parameterized constructor





(b) Complete the code given below to create an object of Scanner class:   [2]

Ans.     Scanner sc=new Scanner (System.in);


© What is an array? Write a statement to declare an integer array of 10 elements[2]

Ans.   An array is a structure created in memory to store multiple similar type of data under a single subscripted variable name.

int a[]=new int[10];

(d) Name the search or sort algorithm that :       [2]

(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 :  Selection sort

(ii) At each stage, compares the sought key value with the key value of the middle element of the array: Binary search


(e) Differentiate between public and private modifiers for members of a class [2]

Ans. The scope of private members of a class is within the class itself whereas the the scope of the public members of a class is outside the class also ( outside the package also).

Question 3.

(a) What are the values of x and y when the following statements are executed?[2]

int a=63, b=36;

boolean x = (a>b) ? true :  false ;

int y=(a<b) ? a : b;




(b)  State the values of n and ch.      [2]

char c=’A’;

int n=c+1;

char ch=(char)n;

Ans.    n=66        ,      ch=B


© What will be the result stored in x after evaluating the following expression?[2]

int x = 4;

x+= (x++)+(++x)+x;




(d) Give output of the following program segment:     [2]

double  x= 2.9 ,  y=2.5;






(e)  State the output of the following program segment:   [2]

String s=”Examination”;

int n=s.length();


System.out.println(s.charAt(2) == s.charAt(6));




(f) State the method that:      [2]

(i)  Converts a string to a primitive float data type   :  parseFloat()

(ii) Determines if the specified character is an upper case character: isUpperCase()


(g)  State the data type and values of a and b after the following segment is executed:     [2]

String  s1= “Computer”,  s2=“Applications”;

a = (s1.compareTo(s2));

b = (s1.equals(s2));

Ans.  a=2  or  positive          data type :   int

b=  false          data type :    boolean

(h)  What will the following code output:       [2]

String s= “malayalam”;






(i) Rewrite the following program segment using while instead of for statement[2]

int f=1,I;

for(i=1; i<=5; i++)


f*=i; System.out.println(f);}


int f=1,  i=1;

while (i<=5)






(j)  In the program given below:        [2]

class MyClass{

static int x = 7;

int y = 2;

public static void main(String args[]){

MyClass obj = new MyClass();



int a= 6;



void sampleMethod(int n){





State the name and value of the :

(i) method argument or argument variable:      5

(ii)  class variable  :   x

(iii)  local  variable:    a

(iv)  instance variable :  y


SECTION B(60 Marks)

Answer any four questions

Also write the variable description/pneumonic codes


Question 4.

Define a class called Library with the following description:

Instance variables/data members:

Int acc_num         : stores the accession number of books

String title            : stores the title of book

String author        :  stores the name of author

Member methods:

Void input() :  to input and store the accession number, title and author

Void compute():  to accept the number of days late, calculate and display the fine charged t the rate of Rs. 2 per day

Void display():   to display the details in the following format:

Accession number             Title         Author

Write the main method to create an object of the class and call  the above member methods                    [15]


import java.io.*;

class Library  {

int  acc_num;

String title, author;

void input()   throws  IOexception{

BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));

System.out.println(“enter the accession number, title and author”);

acc_num= Integer.parseInt(obj.readLine());

title= obj.readLine();

author = obj.readLine();


void compute()  throws IOException{

BufferedReader obj=new BufferedReader(new InputStreamReader(System.in));

System.out.println(“enter the number of days late”);

int n= Integer.parseInt(obj.readLine());

int fine=n*2;

System.out.println(“fine :  “+fine);


void display()  {

System.out.println(“Accession Number\t\tTitle\t\tAuthpr”);



public static void main(String args[]) throws IOException


Library ob=new Library();


ob. compute();




Question 5.

Given below is a hypothetical table showing rates of income tax for male citizens below the age of 65 yrs:

Does not exceed Rs. 1,60,000        -nil

Is > Rs. 1,60,000 & <=Rs. 50,000   – (TI- 1,60,000)*10%

Is >Rs.5,00,000  & <=Rs. 8,00,000  -  [(TI-5,00,000)*20%]+34,000

Is >Rs. 8,00,000 – [(TI-8,00,000)*30%]+94,000

Write a program to input the age, gender(male or female) and taxable income(TI) of a person.

If the age is more than 65 yrs or the gender is female, display “wrong category”.

If the age is less than or equal to 65 yrs and the gender is male, compute and display the income tax payable as  per the table given above.         [15]


import java.io.*;

class IncomeTax {

public static void main(string args[]) throws IOException


BufferedReader ob=new BufferedReader(new InputStreamReader(System.in));

System.out.println(“enter age,  gender and taxable income”);

int age=Integer.parseInt(ob.readLine());

String gender= ob.readLine();

int TI=  Integer.parseInt(ob.readLine());

double tax=0.0;

if((age>65) || (gender.equals(“female”)))

System.out.println(“wrong category”);

else if((age<=65) && (gender.equals(“male”)))




else if(TI>160000 && ti<=500000)


else if(TI>500000 && TI<=800000)






System.out.println(“wrong category”);

}//main  ends

} //class ends

Question 6.

Write a program to accept a string. Convert it to uppercase. Count and output the number of double letter words that exist in the string.    [15]


Sample Output:   4


class DoubleLetter  {

void count(String s1) {


int l=s.length();

int c=0;

for( int p=0; p<l-1;  p++)


if(s.charAt(p) == s.charAt(p+1))


}//for ends

System.out.println( c  );

}//method ends

}//class ends

Question 7.

Design a class to overload a function polygon() as follows:       [15]

(i) void polygon(int n, char ch)  :   with one integer argument and one character type argument that draws a filled square of side n using the character stored in ch.

(ii) void polygon(int x, int y) :  with two integer arguments that draws a filled rectangle of length x and breadth y, using the symbol ‘@’

(iii) void polygon() :  with no argument that draws a filled triangle shown below:


* *

* * *


class Overload  {

void polygon(int n , char ch)   {

for (int  p= 1;  p<=n;  p++)


for(int q=1; q<=n; q++)




}//method ends

void  polygon(int x, int y)  {

for(int p = 1;   p<=x;  p++)


for ( int q=1;  q<=y; q++)




}//method ends

void polygon()  {

for(int p= 1; p<=3; p++)


for( int q=1; q<=p; q++)




}//method ends

}//class ends

Question 8.

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,….

(ii) find the sum of the digits of an integer that is input. Eg 15390=18

For an incorrect choice, appropriate error message should be displayed.  [15]


import java.io.*;

class Menudriven    {

public static void main(String args[])  throws  IOException


BufferedReader ob=new BufferedReader (new InputStreamReader (System.in));

System.out.print(“Enter 1 for Fibonacci numbers/ 2 for sum of digits”);

int ch=Integer.parseInt(ob.readLine());

switch( ch)


case 1:

int a=0, b=1, c;

System.out.print(a+  “    “+ b);

for(int p=3; p<=10; p++)



System.out.print(“   “+c);



}//for ends


case 2:

System.out.println”\nenter an integer”);

int n = Integer .parseInt(ob.readLine());

int rem=0, sum=0;



rem= n%10;



}//while ends

System.out.println(“\nsum of digits  “+sum);



System.out.println(“ Incorrect choice. Enter 1 or 2 only”);

}//switch ends

}//main ends

}//class ends

Question 9.

Write a program to accept the names of 10 cities in a single dimension string array and their STD codes in another single dimension integer array. Search for a name of a city input by the user in the list. If found, display “search successful” and print the name of the city along with its STD code, or else display the message” search unsuccessful, no such city in the list”.    [15]


import java.io.*;

class LinearSearch {

void find(String city[]  ,  int std[])


BufferedReader ob=new BufferedReader (new InputstreamReader (System.in));

System.out.print(“Enter the city to be searched”);

String ele = ob.readLine();

int c=0;

for(int p=0;  p<10; p++)


if(city[p] . equals(ele))




} //end if

}//end for



System.out.print(“Search Successful”);

System.out.print(“City:   “+city[p]+”\tSTD  :”+std[p]);



System.out.print(“Search Unsuccessful. No such city in the list”);

}//end method

}//end class



About these ads
  1. Anonymous
    February 22, 2013 at 9:00 am | #1

    nice paper

  2. Anonymous
    February 21, 2013 at 3:53 pm | #2

    have they ever asked scanner class program questions in board?

  3. Anonymous
    February 21, 2013 at 3:48 pm | #3

    do they ask scanner class programs?

  4. LoveComp
    February 19, 2013 at 1:22 pm | #4

    Question 8, isn’t it supposed to be


    • February 19, 2013 at 3:48 pm | #5

      @lovecomp: Section B Q8(ii)…yes but how is mine different?

  5. Vishal Singh
    February 14, 2013 at 7:20 pm | #6

    if we are told to take out the average of the elements in an array,do we have to find out the sum of the array in another loop,or can we just add the array elements in the loop where we take the input?? for eg.-

    • February 14, 2013 at 8:00 pm | #7

      @vishal: this is correct. you can add array elements while inputting them.

      • Vishal Singh
        February 18, 2013 at 7:22 pm | #8

        my teacher told that we get some extra marks for inputing them in some other loop..he suggested me to run another loop

        • February 19, 2013 at 10:52 am | #9

          @vishal:logically adding array elements while inputting them is correct but from examination point of view what your teacher says is correct not because it gives extra marks but because that brings clarity in the program. For board exams try to use very simple and clear logic so that it does not confuse the examiner and helps in fast correction.

  6. February 10, 2013 at 7:35 am | #10

    Mam, when i typed the solution of the program in question 4, I got errors while compiling, which said- Illegal Character :/ 8992 . What is the reason for that?

    • February 10, 2013 at 10:05 am | #11

      @someone: when you copy-paste a code from wordpress the special characters like , “, ‘ , etc give this problem. So re-type them, it will work

  7. Anonymous
    February 10, 2013 at 7:32 am | #12

    Mam, when i typed the solution of the program in question no.4, I got errors while compiling, which said- Illegal Character :/ 8992. What is the reason?

    • February 10, 2013 at 10:05 am | #13

      @someone: when you copy-paste a code from wordpress the special characters like , “, ‘ , etc give this problem. So re-type them, it will work

  8. Anonymous
    February 8, 2013 at 11:29 pm | #14

    i wanted to know that is it necessary to call the function(polygon)??

    • February 9, 2013 at 5:06 pm | #15

      @someone: this is a question on overloaded functions and since they have not asked to create object and call polygon() method, it is optional for you to call it.

  9. Anonymous
    February 6, 2013 at 3:28 pm | #16

    Do not use string buffer.. It is out of portions

  10. Anonymous
    February 2, 2013 at 11:23 am | #17

    thxs mam this is really very useful………

  11. Adithya Rajendran
    February 2, 2013 at 8:43 am | #18

    Thanks a lot mam….this helped me a lot!!!!

  12. February 1, 2013 at 8:10 am | #19

    ma’am pls send the solution

  13. Vishal Singh
    January 29, 2013 at 2:48 pm | #20

    Is it important to use Buffered Reader in all the programs??……..Can we use Scanner?…….Or can just do the program without both Scanner and Buffered Reader???

    • January 30, 2013 at 9:46 am | #21

      @vishal: you can use either BufferedReader or Scanner classes for taking inputs in programs when explicitly mentioned otherwise you can take inputs through parameters only. But one of these two classes have to be used in menu-driven programs.

  14. Anonymous
    January 28, 2013 at 7:14 pm | #22

    answers are outstanding it helped me much

  15. January 20, 2013 at 8:41 pm | #24

    hello mam….
    i need your help in making a program
    tic tac game by multi dimensional array
    would u please help me…..????????

  16. pariii
    January 20, 2013 at 8:37 pm | #25

    i need your help in making a program
    tic tac toe game by multi dimensional array
    would u please help me??????????

    • January 21, 2013 at 7:38 pm | #26

      @parii: this program code is posted under the category java-> games

  17. January 18, 2013 at 4:02 am | #27

    .Thanks for posting this mam,………..,..But i want to know that is variable discription important or worth of marks ? :)

    • January 18, 2013 at 4:06 am | #28


      • January 18, 2013 at 9:16 am | #29

        @aakash: variable description may be given before or after each program code in Section B of the question paper. It states the purpose of each variable used in the program and is given under two headings ‘variable’ and ‘used for’ eg. sum – to store the sum of the series, i – loop control variable to generate array indices, etc

        • January 19, 2013 at 5:16 am | #30

          ….Thanks ma’am ……….. Yesterday was my pre-board exam n i will almost score full marks……….but the paper was so easy that it was boring…..

  18. Anonymous
    January 17, 2013 at 6:28 am | #31

    Thank you so much.

  19. Shubham Agrawal
    January 12, 2013 at 6:19 pm | #32

    Mam, thanks to u for posting the answers but i want to know HOW AND WHERE to give the VARIABLE DESCRIPTIONS or mnemonic codes while writing the answers.
    Thanks a lot.

    • January 13, 2013 at 8:44 am | #33

      @Shubham: variable description can be given before or after each program in Section B. Just describe the variables used in your program codes under two headings ie. “variable” and “used for”

      • Shubham Agrawal
        January 13, 2013 at 10:57 am | #34

        thanks a lot mam :-):-)

  20. January 9, 2013 at 6:59 pm | #35

    Thank you so much.
    This’s helping me a lot.

  21. Anonymous
    January 9, 2013 at 6:57 pm | #36

    This helped me a lott.
    Thank you so much Ma’am.

  22. kartiki
    January 9, 2013 at 5:35 pm | #37

    thanks to u

  23. Niharika
    January 6, 2013 at 1:35 pm | #38

    i needed that, thanks a tonne:)

  24. December 30, 2012 at 10:14 am | #39

    solved paper needs improvement at many places

    • January 7, 2013 at 9:45 am | #40

      @manas: there may be some typing errors. i will check them . thanks.

  25. montish raj
    December 25, 2012 at 10:34 am | #41


  26. kasthuri
    December 24, 2012 at 9:08 am | #43


  27. Ishan
    December 17, 2012 at 3:28 am | #44


  28. November 24, 2012 at 6:38 pm | #45

    thank q

  29. November 20, 2012 at 2:39 pm | #46

    itt…………………. help me lot ……………………………………….thax

  30. akash
    November 10, 2012 at 10:36 am | #47

    i liked it……assume……..my java programs have somewhat improved

  31. Anonymous
    September 26, 2012 at 2:22 pm | #48

    Thanx Amita Ma’am..

    Rakesh Bhatia

  32. monil
    September 24, 2012 at 3:47 pm | #49

    are the soln rite??????

  33. September 22, 2012 at 12:26 pm | #52

    Question 6.

    Write a program to accept a string. Convert it to uppercase. Count and output the number of double letter sentences that exist in the string. [15]


    Sample Output: 4

    Ms Suri, do you not think there is a problem in the question itself? The question says output the number of double letter “sentences”. The string itself is just one sentence. The question should have said “words” instead of sentences.

    Now, if the number of “words” is to be output, then your solution is not ok. It is displaying the number of times two letters come together. So if a word has more than one pair occurring, then it will show, but it is still one word. Your program will display 2.

    • September 23, 2012 at 11:55 am | #53

      @Mr. Koura: Thanks for pointing the error. It was a typing error and I have corrected it.

      Coming to the logic, what you said is right. But this question paper is for an ICSE (class 10th) student and the programs are meant to be solved according to the given sample input and output. Had it been for an ISC (class 12th) student, level of testing would have been complex with more checks required.

    • Danda Jain
      February 22, 2013 at 10:15 am | #54

      @Mr.Koura read the question again…uncle…there’s nowhere given ‘sentences’…its your sight problem….read it again,u’ll get ti….

      • February 22, 2013 at 5:12 pm | #55

        @danda: Mr. Koura had pointed it out correctly . Later ‘sentence’ was changed to ‘word’.

  34. ujjwal
    September 12, 2012 at 2:42 pm | #56

    Write a java program to accept a sentence and print only the first letter of each word of the sentence in capital letters separated by a full stop.
    Write a java program to calculate the sum of all the prime numbers between the range of 1 to 100.

    • September 15, 2012 at 10:41 am | #57

      @ujjwal: many related string and series programs are already posted on my site . you can modify them a little to get the stated programs

  35. Adarsh
    September 6, 2012 at 3:40 pm | #58

    not so tough..!!

Comment pages
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

Join 196 other followers

%d bloggers like this: