ICSE Class 10 Computer Application Solved Question Paper Year 2015


COMPUTER APPLICATIONS ICSE – 2015
(Theory)
(Two Hours)

Answer to this paper must be written on the paper provided separately.
You will not be allowed to write during the first 15 minutes.
This time is to be spent in reading the question paper.
The time given on the head of this paper is the time allowed for writing the answer.
This Paper is divided into Sections.
Attempt all questions from Section A and any four from Section B.
The intended marks for questions or parts of questions are given in brackets [ ]

SECTION A (40 MARKS)

Attempt all questions

Question 1

  1. Marks [2]

    What are the default values of the primitive data type int and float?
    Ans. Default Values:
    int 0
    float 0.0f

  2. Marks [2]

    Name any two OOP’s principles.
    Ans.Two OOP’s principles are;
    1 Polymorphism
    2 Encapsulation

  3. Marks [2]

    What are identifiers?
    Ans.Identifiers are fundamental building blocks of java program.
    They are a general terminology used for arrays, strings, primitive data members etc. They have specific naming rules.
    Eg, int n = 1; n is an identifier.

  4. Marks [2]

    Identify the literals listed below:
    (i) 0.5 (ii) ‘A’ (iii) false (iv) “a”.
    Ans. The literals are;
    (i) 0.5 – Real Literal
    (ii) ‘A’ – Character Literals
    (iii) false – Boolean Literal
    (iv) “a” – String Literal

  5. Marks [2]

    Name the wrapper classes of char type and boolean type.
    Ans.Wrapper a classes of:-
    char – Character
    booloan – Boolean

Question 2

  1. Marks [2]

    Evaluate the value of n if value of p= 5, q=19
    int n = (q-p)>(p-q) ? (q-p) : (p-q);
    Ans. p=5, q=19
    int n= (q-p)> (p-q)? (q-p): (p-q)
    hence, n = (q-p) is applicable
    = 19-5 = 14

  2. Marks [2]

    Arrange the following primitive data types in an ascending order of their size:
    (i) char (ii) byte (iii) double (iv) int.
    Ans.Arranging according to size
    byte < char < int < double.

  3. Marks [2]

    What is the value stored in variable res given below:
    double res = Math.pow (“345”.indexOf(‘5’), 3);
    Ans.
    double res = Math.pow (“345”.IndexOf (‘5’),3);
    =Math.pow (2,3), As because (“345”.IndexOf (‘5’) is 2
    = 8.0

  4. Marks [2]

    Name the two types of constructors.
    Ans.
    Two types of constructor are:
    Default constructor and Parameterised constructor.

    Example
    Default
    class Student
    {
    Student( )
    {
    }
    }

    Parameterised
    class Student
    {
    int roll;
    String name;
    Student (int r, String n)
    {
    roll = r;
    name = n;
    }

    }

  5. Marks [2]

    What are the values of a and b after the following function is executed, if the values passed are 30 and 50:
    void paws( int a, int b)
    {
    a= a+b;
    b=a-b;
    a=a-b;
    System.out.println( a+ “, “+b);
    }
    Ans.
    Output:
    50,30

Question 3

  1. Marks [2]

    State the data type and value of y after the following is executed:
    char x=’7′;
    y=Character.isLetter(x);
    Ans.
    char x = ‘7’
    y = Character.is Letter (x);
    y = false
    Data type in y is of Boolean type

  2. Marks [2]

    What is the function of catch block in exception handling? Where does it appear in a program?
    Ans.
    Catch block contains all the statements that are to be executed when an error has been detected in the corresponding try block.
    So catch helps us to complete our operations even if an error occurs.
    It occurs after the try block in a java program.

    Example of a try-catch block
    BufferedReader br=new BufferedReader( new InputStreamReader(System.in));
    try
    {
    inData = Integer.parseInt(br.readLine());
    }
    catch(NumberFormatException nfEx)
    {
    System.out.println(“Input format is incorrect”);
    }

  3. Marks [2]

    State the output when the following program segment is executed:
    String a =”Smartphone”, b=”Graphic Art”;
    String h=a.substring(2,5);
    String k= b.substring(8).toUpperCase( );
    System.out.println(h);
    System.out.println(k.equalsIgnoreCase(h));
    Ans.
    Output:-
    art
    true

  4. Marks [2]

    The access specifier that gives the most accessibility is_ _ and the least accessibility is _ _.
    Ans.
    The access specifier that gives maximum visibility is public and the least accessibility is private.

  5. Marks [2]
    1. Name the mathematical function which is used to find sine of an angle given in radians.
    2. Name a string function which removes the blank spaces provided in the prefix and suffix of a string.

    Ans.

    1. Math.sin() is used to find the sine of an angel in radians.
    2. trim()is used to remove blank spaces from both ends of the string.
  6. Marks [2]
      1. What will this code print?
        int arr[] =new int [5];
        System.out.println(arr);
        (i) 0 (ii) value stored in arr[0] (iii) 0000 (iv)garbage value
      2. Name the keyword which is used to resolve the conflict between method parameter and instance variables/fields.

    Ans.

      1. (iv)garbage value.
      2. The ‘this’ keyboard remove conflict between method parameter and instance variables having same name.
        Example
        class Student
        {
        int rollno;
        String name;Student(int rollno, String name)
        {
        this.rollno = rollno;
        this.name = name;
        }———————
        ———————
        }Output:
        101 Arpan
        102 Arnab
  7. Marks [2]

    State the package that contains the class:
    (i)BufferedReader
    (ii)Scanner
    Ans.
    The package that contains:
    (i)Buffered reader – java.io
    (ii)Scanner – java.util

  8. Marks [2]

    Write the output of the following program code:
    char ch;
    int x=97;
    do
    {
    ch=(char)x;
    System.out.print(ch+””);
    if(x%10=0)
    break;
    ++x;
    }while(x<= 100);
    Ans.
    Output:-
    a,b,c,d

  9. Marks [2]

    Write the Java expressions for:
    a2+b2;
    2ab
    Ans. (Math,pow(a,2) + (Math.pow(b,2))
    2.*a*b.

  10. Marks [2]

    If int y= 10 then find int z = (++y *(y++ +5));
    Ans.
    z = 176

SECTION B (60 MARKS)

Attempt any four questions from this Section.
The answers in this Section should consist of the Programs in either Blue J
environment or any program environment with Java as the base.
Each program should be written using Variable description/Mnemonic Codes
so that the logic of the program is clearly depicted.
Flow-Charts and Algorithms are not required.

Question 4

Marks [15]

Define a class called ParkingLot with the following description:
Instance variables /data members:
int vno – To store the vehicle number
int hours – To store the number of hours the vehicle is parked in the parking lot
double bill: To store the bill amount
Member methods:
void input( ) – To input and store the vno and hours.
void calculate( ) – To compute the parking charge at the rate of ` 3 for the first hour or part thereof, and ` 1.50 for each additional hour or part thereof.
void display( ) – To display the detail
Write a main method to create an object of the class and call the above methods.
Ans.

import java.io.*;
class parkingLot
{
int vno;
int hours;
double bill;
void input( ) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter the vehicle number is: ");
vno = Integer.parseInt(br.readLine());
System.out.print("Enter number of hours the vehicle is parked in: ");
hours = Integer.parseInt(br.readLine());
}
void calculate( )
{
if(hours <= 1)
{
bill = hours *3;
}
else
{
bill = 1 *3.0 +(hours -1) * 1.5;
}
}
void display( )
{
System.out.println("The Vehicle number is: " +vno);
System.out.println("The number of hours are: " +hours);
System.out.println("The bill is Rs.: " +bill);
}
public static void main(String args[ ])throws IOException
{
parkingLot car1 = new parkingLot( );
car1.input( );
car1.calculate( );
car1.display( );
}
}

Question 5

Marks [15]

Write two separate programs to generate the following patterns using iteration (loop) statements:
(a) * (b) 54321
*# 5432
*#* 543
*#*# 54
*#*#* 5
Ans.

  1. import java.io.*;
    class loop1
    {
    public static void main(String args[ ])throws IOException
    {
    int i,j;
    for(i=1;i<=5;i++)
    {
    for(j=1;j<=i;j++)
    {
    if(j%2==1)
    System.out.print("*");
    else
    System.out.print("#");
    }
    System.out.println("");
    }
    }
    }	
    </li>
    <li>
    import java.io.IOException;
    class loop2
    {
    public static void main(String args[]) throws IOException
    {
    int i, j;
    for (i = 1; i <= 5; i++)
    {
    for (j = 5; j >= i; j--)
    {
    System.out.print(j);
    }
    System.out.println();
    }
    }
    }
    </li>
    

Question 6

Marks [15]

Write a program to input and store roll numbers, names and marks in 3 subjects of n number students in five single dimensional array and display the remark based on average marks as given below: (The maximum marks in the subject are 100)

Average marks Remark
85-100 EXCELLENT
75-84 DISTINCTION
60-74 FIRST CLASS
40-59 PASS
Less than 40 POOR

Ans.

import java.io.*;
public class ClassManagement
{
public static void main(String[] args)throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.print("Enter number of students: ");
int n = Integer.parseInt(br.readLine());
int[] roll = new int[n];
String[] name = new String[n];
int[] phy = new int[n];
int[] che = new int[n];
int[] comp = new int[n];
int[] avg = new int[n];
String[] grade = new String[n];
for(int i = 0; i<n; i++)
{
System.out.println("Enter Data of student: " +(i+1) +":-");
System.out.print("Enter Roll Number: ");
roll[i] = Integer.parseInt(br.readLine());
System.out.print("Enter Name: ");
name[i] = br.readLine();
System.out.print("Enter Physics Marks: ");
phy[i] = Integer.parseInt(br.readLine());
System.out.print("Enter Chemistry Marks: ");
che[i] = Integer.parseInt(br.readLine());
System.out.print("Enter Computer Marks: ");
comp[i] = Integer.parseInt(br.readLine());
avg[i] = (phy[i] + che[i] +comp[i])/3;
if(avg[i] >= 85)
grade[i]="EXCELLENT";
else if(avg[i] >= 75 && avg[i] <= 84)
grade[i]="DISTINCTION";
else if(avg[i] >= 60 && avg[i] <= 74)
grade[i]="FIRST CLASS";
else if(avg[i] >= 40 && avg[i] <= 59)
grade[i]="PASS";
else
grade[i]="POOR";
}
for(int j = 0; j<n; j++)
System.out.println(roll[j] +"\t" +name[j] +"\t" +avg[j] +"\t" +grade[j]);
}
}

Question 7

Marks [15]

Design a class to overload a function Joystring( ) as follows:

  1. void Joystring(String s, char ch1, char ch2) with one string argument and two character arguments that replaces the character argument ch1 with the character argument ch2 in the given string s and prints the new string.
    Example:
    Input value of s -“TECHNALAGY” chl=’A’, ch2=’O’Output: “TECHNOLOGY”
  2. void Joystring(String s) with one string argument that prints the position of the first space and the last space of the given string s.
    Example:
    Input value of =”Cloud computing means Internet based computing”Output: First index: 5 ,
    Last index: 36
  3. void Joystring( String si, String s2 ) with two string arguments that combines the two strings with a space between them and prints the resultant string.
    Example:
    Input value of s1 = “COMMON WEALTH ”
    Input value of s2 = “GAMES ” Output: COMMON WEALTH GAMESOutput:
    Output: COMMON WEALTH GAMES
    (use library functions)

Ans.

import java.io.*;
public class JoyOfString
{
static void Joystring(String s, char ch1, char ch2)
{
s = s.replace(ch1, ch2);
System.out.print("New String: " +s);
}
static void Joystring(String s)
{
System.out.println("first space and the last space of the given string");
System.out.println("First index : " +s.indexOf(" "));
System.out.println("Last index: " +s.lastIndexOf(" "));
}
static void Joystring(String s1, String s2) 
{
s1 = s1 + " ";
System.out.print(s1.concat(s2));
}
public static void main(String[] args)throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str;		
try
{
System.out.println("Inputs for 1st Method of String: ");
System.out.print("Enter a Word: ");
str = br.readLine();
System.out.print("Enter a Character that would replaced: ");
char crep = (char) System.in.read();
br.readLine();
System.out.print("Enter a Character that would replaced with: ");
char crepw = (char) br.read();
br.readLine();
Joystring(str, crep, crepw);
System.out.println("\nInput for 2nd Method of String: ");
System.out.print("Enter a String: ");
str = br.readLine();
Joystring(str);
System.out.println("\nInputs for 3rd Method of String: ");
System.out.print("Enter 1st String: ");
String str1 = br.readLine();
System.out.print("Enter 2nd String: ");
String str2 = br.readLine();
Joystring(str1, str2);
}
catch(IOException e)
{
e.printStackTrace();
}
}
}

Question 8

Marks [15]

Write a program to input twenty names in an array. Arrange these names in descending order of alphabets, using the bubble sort technique.

Ans.

import java.io.*;
public class BubbleSortNamesArray
{
public static void bubbleSort(String[] array)
{
String temp; 
int n = array.length;
for(int i = 1; i<n; i++)
{
for(int j = 0; j<n-i; j++)
{
if(array[j].compareToIgnoreCase(array[j+1]) > 0)
{
temp = array[j];
array[j] = array[j + 1];
array[j + 1] = temp;
} 
}
}
}	
public static void main(String [] args)throws IOException
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
int len = 20;
String[] stringArray = new String[len];
char Ini;
String IniS;
int i;
for(i=0; i<len; i++)
{
System.out.print("Enter Name: ");
stringArray[i] = input.readLine();
//Below Lines are for Transforming data to Initials Caps and all in Small
stringArray[i]=stringArray[i].toLowerCase();
Ini = stringArray[i].charAt(0);
IniS = Ini +"";
IniS=IniS.toUpperCase();
stringArray[i] = stringArray[i].substring(1, stringArray[i].length());
stringArray[i] = 	IniS +	stringArray[i];
}
bubbleSort(stringArray);
System.out.println("---Final---");
for(i = 0; i < len; i++)
{
System.out.print(stringArray[i] + "  ");
}
System.out.println();
}
}

Question 9

Marks [15]

Using the switch statement, write a menu driven program to:

  1. To find and display all the factors of a number input by the user (including 1 and excluding number itself).
    Example:
    Sample Input : n = 15
    Sample Output : 1, 3, 5
  2. 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.

Ans.

import java.io.*;
public class FactCase
{
public static void main(String [] args)throws IOException
{
BufferedReader input = new BufferedReader(new InputStreamReader(System.in));
System.out.print("MENU:\n1. Factors\n2. Factorial\nEnter your choice: ");
int choice = Integer.parseInt(input.readLine());
switch(choice)
{
case 1:
System.out.print("Enter a Number to find its Factors: ");
int facts = Integer.parseInt(input.readLine());
int factorNumber = 1;
while(factorNumber < facts)
{
if(facts % factorNumber == 0)
{
System.out.println(factorNumber + " is a factor of " + facts);
}
factorNumber ++;
}
break;
case 2:
System.out.print("Enter a Number to find its Factorial: ");
int factrl = Integer.parseInt(input.readLine());
long factorial = 1;
System.out.print(factrl +"! = ");
for(int i = 1; i<= factrl; i++)
{
factorial = i * factorial;
if(i<factrl)
System.out.print(i +" X ");
else
System.out.print(i +" = ");	
}
System.out.print(factorial);
break;
default:
System.out.println("Enter your choice correctly!!!");
break;
}
}
}

Add a Comment

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.