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
    July 7, 2014 at 2:10 pm

    This is a very good site. Please visit it to get any help for project work. :-)

  2. December 21, 2013 at 8:05 am

    Very nice post. I just stumbled upon your blog and wished to
    say that I have really enjoyed surfing around your blog posts.
    In any case I’ll be subscribing to your rss feed and I hope you write again soon!

  3. Abhinav Srivastava
    May 31, 2013 at 12:08 pm

    Ma’am could you please tell me how to do : (x)! / 10 + (x +2)! /15 + (x+4)! /20 + (x+n)! /m program ..Ma’am please reply at the earliest

  4. Anonymous
    May 6, 2013 at 4:48 pm

    thanks.. was quite helpful!!!!!!!!!!

  5. May 2, 2013 at 11:32 pm

    Have you ever considered writing an ebook or guest authoring on other
    websites? I have a blog centered on the same subjects you discuss and would really like to have you share
    some stories/information. I know my viewers would appreciate your work.
    If you are even remotely interested, feel free to send me an e mail.

  6. Penthaa
    March 11, 2013 at 4:25 pm

    Mam, In today’s exam, there was a program similar to Question 7 above.The question in the exam was to design a class to overload a function series(). In the program, I have called the function too using buffered reader, so will that affect my marks?

    • March 12, 2013 at 10:31 pm

      @penthaa: only overloading was asked. i think you must have created the main() method and called the overloaded methods on choice. as far as overloading is correct, marks should not be deducted

  7. Penthaa
    March 11, 2013 at 10:58 am

    Mam, which is the keyword that stores the address of the currently-calling object?

    • March 11, 2013 at 11:24 am

      @penthaa: keyword ‘this’

      • Penthaa
        March 11, 2013 at 11:46 am

        that means my answer is correct in the exam!..thank u ma’am

  8. March 10, 2013 at 1:35 pm

    good solutions but not real to do exams

  9. Penthaa
    March 10, 2013 at 12:00 pm

    Question-Define a class ‘Student‘ described as below:
    Data members/instance variables : name,age,m1,m2,m3 (marks in 3 subjects),maximum, average marks
    Member methods :
    (i) A parameterized constructor to initialize the data members.
    (ii) To accept the details of a student.
    (iii) To compute the average and the maximum out of three marks.
    (iv) To display the name, age, marks in three subjects, maximum and average.
    Write a main method to create an object of a class and call the above member methods

    Mam, how to initialize the data members using a parameterized constructor for this question?
    Does the data entered from the console while execution (using buffered reader) gets initialized or do we enter the data while creating an object?

    • March 10, 2013 at 1:57 pm

      @penthaa: There is an error in the question .Since input() method is given to accept the details, inputs have to be taken there only either using buferedreader or scanner class. so constructor should not be parameterized here. it should have been used just to initialize constant values

      • Penthaa
        March 10, 2013 at 3:00 pm

        Thanks a lot mam for helping me out….

  10. March 10, 2013 at 11:23 am

    Ma’am ..how do i write these so calles “variable description”? i have no idea..please help

    • March 10, 2013 at 11:27 am

      @vivek: i will post it under icse computer aplications. check it there later

  11. Penthaa
    March 10, 2013 at 11:22 am

    Question-Define a class ‘Student‘ described as below: [15]

    Data members/instance variables : name,age,m1,m2,m3 (marks in 3 subjects),maximum, average marks
    Member methods :
    (i) A parameterized constructor to initialize the data members.
    (ii) To accept the details of a student.
    (iii) To compute the average and the maximum out of three marks.
    (iv) To display the name, age, marks in three subjects, maximum and average.

    Write a main method to create an object of a class and call the above member methods

    Mam, how to initialize the data members using a parameterized constructor for this question?
    Does the data entered from the console while execution (using buffered reader) gets initialized or do we enter the data while creating an object?

  12. ivan
    March 10, 2013 at 11:10 am

    mam could u pls post a program of finding whether a entry from the user is pallindrome or not(for both string and numbers) using stringbuffer

  13. March 10, 2013 at 10:11 am

    give me the program of niven number eg is =1729 so 1+7+2+9=19 hence 19*91=1729 can u really do it

    • March 10, 2013 at 10:46 am

      @dharna: here’s the algorithm
      1. extract digits by using the division remainder method and sum them by using an accumulator
      2. reverse the sum and form a new number by same method
      3. find product of sum and its reverse number
      4, check if it is same as the original number then i is a niven number

      Hope this helps and you can convert this algorithm to program code

  14. ivan
    March 10, 2013 at 7:46 am

    forgive me if im wrong but i think it should be





    }//while ends

    • March 10, 2013 at 11:01 am

      ivan: thanks ivan for pointing it out. it was a typing error. i have corrected it

  15. ivan
    March 10, 2013 at 7:31 am

    im sorry it was right but sum is showing 0

  16. March 10, 2013 at 5:37 am

    MAM given up 1st program in section B is using funtions or constructors and in that same program we can write bufferd reader at the end of the program

    • March 10, 2013 at 11:25 am

      @rajjan: As in this question, when class specification is given , you have to do it accordingly. you cannot change it. and since inputs are asked to be taken in the input() method, you have to take them there only and not in the main() method

  17. Viranchi
    March 9, 2013 at 3:50 pm

    madam! your 4th answer is showing an error!!!
    where you have written the compute method you should correct it by writing “throws IOException” because we are inputting the number of days late.
    Hope you would correct it soon so that others may not have any problem in solving the error.

  18. March 3, 2013 at 7:08 am

    Thanx mam this helped me a lot… Mam i often get confused by the array programs and pattern programs….. especially sorting and searching with arrays…. how can i overcome them..

    • March 3, 2013 at 3:54 pm

      @vaibhav: Maintain cool while programming especially during exam. Most important is to understand the concepts and learn the syntax of various programming statements as learning progams does not help. Understand the question well and try to apply the logic step by step using various statements wherever required. You can also go thru my posts of understanding patterns and arrays on this website. And since computer exam is very near there is no harm in learning the three sorting and two searching techniques. Arrays and Patterns both are important for the board exam.

      • vaibhav
        March 3, 2013 at 4:19 pm

        Thank you mam….

  19. GueSS wHo...
    March 2, 2013 at 9:26 am

    hmm..nice work..must say..but doesn’t help if v r’nt loyal to ourselves…

  20. Danda Jain
    February 22, 2013 at 10:17 am

    when we do function overloading,while calling the fuction,can we just input values by ourselves???…

    • February 22, 2013 at 5:05 pm

      @danda: it depends upon the question whether inputs have been asked/required or not. For example, to display 1st 10 terms of the fibonacci series does not require any input

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 199 other followers

%d bloggers like this: