ICSE Class 10 Computer Application Solved Question Paper Year 2017


COMPUTER APPLICATIONS ICSE – 2017
(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 is inheritance?
    Ans.
    It is the process by which objects of one class acquire the properties of objects of another class. In OOP the concepts of inheritance provides the idea of re-usability.

  2. Marks [2]

    Name the operators listed below:

    1. <
    2. ++
    3. &&
    4. ?:

    Ans.

    1. Relational Operator
    2. Increment Operator
    3. Logical Operator
    4. Ternary Operator
  3. Marks [2]

    State the number of bytes occupied by char and int data types.
    Ans.
    int 4 bytes.
    char 2 bytes.

  4. Marks [2]

    Write one difference between / and % operator.
    Ans.

      The arithmetical operator / is used to find quotient of two numbers. E.g.: 7/3 is 2.
      The arithmetical operator % is used to find the remainder. E.g.: 7%3 is 1.
    1. Marks [2]

      String x[] = {“SAMSUNG”, “NOKIA”, “SONY”, “MICRQMAX”, “BLACKBERRY”};
      Give the output of the following statements:

      1. System.out,println(x[1]);
      2. System.outprintln(x[3].length ())

      Ans.Values for p and q

      1. NOKIA
      2. 8
        Work out: x[3] = “MICRQMAX”
        So, the total number of character presents in the word: 8
        Hence, x[3].length () = 8

    Question 2

    1. Marks [2]

      Name the following:

      1. A keyword used to call a package in the program.
      2. Any one reference data type.

      Ans.

      1. import
      2. array
    2. Marks [2]

      What are the two ways of invoking functions?
      Ans.
      The two ways of invoking functions.

      • Call by value
      • and Call by reference
    3. Marks [2]

      State the data type and value of res after the following is executed:

      char ch='t';
      res = Character.toUpperCase(ch);
      

      Ans.
      Date type of res is char and value of res will be ‘T’, if it is not explicitly converted

    4. Marks [2]

      Give the output of the following program segment and also mention the number of times the loop is executed:

      int a,b;
      for (a = 6, b = 4; a <= 24; a = a + 6)
      {
      if (a%b ==0)
      break;
      }
      System. out.println(a);
      

      Ans.
      Output: 12
      Loop will be execute for 2 times

      Work out
      Loop initialization: a = 6, b = 4

      First iteration:
      Condition check: a <= 24 ie. 6 <= 24 —- true
      Loop is executed for the first time
      Condition execution: a % b = 6 % 4 = 2 != 0 Condition not executed hence, break is not executed
      Loop increment operator: a = a + 6 ie. a = 6 + 6 = 12

      Second iteration:
      Condition check: a <= 24 ie. 12 <= 24 —- true
      Loop is executed for the second time
      Condition execution: a % b = 12 % 4 = 0 = 0 Condition executed, hence, break is executed
      System.out.println(a); — 12

    5. Marks [2]

      Write the output:

      char ch = 'F';
      int m = ch;
      m=m+5;
      System.out.println(m + "" + ch);
      

      Ans.
      Output
      75 F

      Work out
      ch = ‘F’
      int m = ch; — ASCII value of ‘F’(Capital F) i.e. 70 will be assigned to m
      m = m + 5 = 70 + 5 = 75
      System.out.println(m+ ” ” +ch); —- 75 F

    Question 3

    1. Marks [2]

      Write a Java expression for the following:
      ax2+bx2+c
      Ans.
      a * Math.pow(x, 5) + b * Math.pow(x, 3) + c

    2. Marks [2]

      What is the value of x1 if x=5?
      x1 = ++x – x++ + –x
      Ans.
      x1 = ++x – x++ + –x (x = 5) (Solved from LHS to RHS)
      x1 = 6 – x++ + –x (x is incremented by 1 for ++x, so x from 5 to 6)
      = 6 – 6 + –x (x is incremented to 7 but not act over here due to post fix for x++)
      = 6 – 6+ 6 (x is decremented by 1 for x– so x turns from 7 to 6)
      = 6

    3. Marks [2]

      Why is an object called an instance of a class?
      Ans.
      In object-oriented programming (OOP), an instance is a specific realization of any object. An object is called an instance of a class as every object created from a class gets its own instances of the variables defined in the class. Formally, “instance” is synonymous with “object” as they are each a particular value (realization), and these may be called an instance object; “instance” emphasizes the distinct identity of the object. The creation of a realized instance is called instantiation. In real-world example of an object would be ‘Peacock’, which is an instance of a class called ‘Bird’. Multiple objects can be created from the same class.

    4. Marks [2]

      Convert following do-while loop into for loop.

      int i = 1;
      int d=5;
      do {
      d=d*2;
      System.out.println(d);
      i++ ;	}while (i<=5);
      

      Ans.

      for(int i=1, d=5; i<=5; i++)
      {
      d=d*2;
      System.out.println(d);
      }
      
    5. Marks [2]

      Differentiate between constructor and function.
      Ans.

      • A constructor has no return type while a method has a return type.
      • The name of the constructor should be the same as that of the class while the name of a method can have any name that is known as valid identifier.
      • A constructor is automatically invoked upon object creation while methods are invoked explicitly by manual after object creation.
      • A constructor is invoked only once while a function can be invoked multiple times.
    6. Marks [2]

      Write the output for the following:

      String s="Today is Test";
      System.out.println(s.indexOf('T'));
      System.out.println(s.substring(0,7) + " " +" Holiday");
      

      Ans.
      Output is
      0
      Today i Holiday

      Work out
      s.indexOf(‘T’) = 0
      s.substring(0,7)+ ” “+ “Holiday”
      = “Today is Test”.substring(0,7) + ” ” + “Holiday”
      = “Today i” + ” ” + “Holiday”
      = “Today i Holiday”

    7. Marks [2]

      What are the values stored in variables r1 and r2:

      1. double r1 = Math.abs(Math.min(-2.83, -5.83));
      2. double r2 = Math.sqrt(Math.floor(16.3));

      Ans.
      Values that are stored in variables r1 and r2:

      1. 5.83
        [Work out: Math.abs(-5.83) =5.83]
      2. 4.0
        [Work out: Math.sqrt(16) = 4, As Math.floor(16.3) returns 16]
    8. Marks [2]

      Give the output of the following code:

      String  A="26", B="100";
      String  D=A+B+"200";
      int x= Integer.parselnt(A);
      int y = Integer.parselnt(B);
      int d = x+y;
      System.out.println("Result 1 = "+D);
      System.out.println("Result 2 = " +d);
      

      Ans.
      Output:
      Result 1=26100200
      Result 2=126

      Work out
      A = “26″, B = “100″
      Hence, String D = A + B + “200″;
      D = “26″ + “100″ + “200″ = 26100200

      int x= Integer.parseInt(A); [Converts the String value as Integer] x = Integer.parseInt(“26″) = 26

      int y=Integer.parseInt(B); [Converts the String value as Integer] y= Integer.parseInt(B) = Integer.parseInt(“100″); = 100
      Hence, x = 26 and y = 100
      So, int d = x+y;
      = 26 + 100 = 126
      That’s why,
      System.out.println(“Result 1=” +D);
      System.out.println(“Result 2=”+d);
      Generate Outputs as:
      Result 1=26100200
      Result 2=126

    9. Marks [2]

      Analyze the given program segment and answer the following questions:

      for(int i=3;i<=4;i++){
      for(int j=2;j<i;j++){
      System.out.print(" ");}
      System.out.println("WIN");}
      
      1. How many times does the inner loop execute?
      2. Write the output of the program segment.

      Ans.

      1. Inner loop executes 3 times
      2. Output:
        WIN
        WIN

      Work out
      for(int i=3; i<=4; i++)
      {
      for(int j=2; j<i; j++)
      {
      System.out.print(" ");
      }
      System.out.println("WIN");
      }

      The output loop runs twice, for i = 3 and i = 4 only, then terminate the entire loop organization
      When i = 3, the inner loop runs once with j = 2, as j terminates with i less than 3
      When i = 4, the inner loop runs twice with j = 2 and j = 3 then terminates with i less than 4

    10. Marks [2]

      What is the difference between the Scanner class functions next() and nextLine()?
      Ans.
      next( ) can read a single token i.e. all characters from the current position which means the input only till a space, the whitespace or tab or new line is encountered. It can’t read two words separated by space.
      But nextLine( ) reads input as an entire line i.e. all characters from the current position including space between the words (that is, it reads till the end of line \n).

    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 ElectricBill with the following specifications:
    Instance variables /Data members:
    String Bname- stores the name of the book
    double price- stores the price of the book
    Member methods:
    (i) BookFair( )- Default constructor to initialize data members
    (ii) void Input( )- To input and store the name and the price of the book,
    (iii) void calculate( ) – To calculate the price after discount. Discount is calculated based on the following criteria
    Price Discount
    Less than or equal to ` 1000 2% of price
    More than ` 1000 and less than or equal to ` 3000 10% of price
    More than ` 3000 15% of price
    (iv) void display( ) – To display the name and price of the book after discount.
    Write a main method to create an object of the class and call the above member methods.

    Ans.

    import java.io.*;
    public class ElectricBill
    {
    String n;
    int units;
    double bill;
    public void accept()throws IOException
    {
    BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter the customer name: ");
    n = read.readLine();
    System.out.print("Enter Number of units consumed: ");
    units = Integer.parseInt(read.readLine());
    }
    public void calculate()
    {
    if (units <= 100)
    {
    bill = units * 2;
    }
    else if (units > 100 && units <= 300)
    {
    bill = 100 * 2 + (units - 100) * 3;
    }
    else
    {
    bill = 100 * 2 + 200 * 3 + (units - 300) * 5;
    double surcharge = bill * 2.5 / 100;
    bill = bill + surcharge; 
    }
    }
    public void print()
    {
    System.out.println("Name of the customer: "+n);
    System.out.println("Number of units consumed: "+units);
    System.out.println("Bill amount: "+bill);
    }
    public static void main(String args[]) throws IOException
    {
    ElectricBill obj = new ElectricBill();
    obj.accept();
    obj.calculate();
    obj.print();
    }
    }
    

    Question 5

    Marks [15]

    Write a program to accept a number and check and display whether it is a spy number or not. (A number is spy if the sum of its digits equals the product of its digits.)
    Example: consider the number 1124,
    Sum of the digits =1 + 1 + 2 + 4 = 8
    Product of the digits =1 x 1 x 2 x 4 = 8

    Ans.

    import java.io.*;
    public class SpyNumber 
    {
    public static void main(String args[])throws IOException
    {
    BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Enter a Number: ");
    int no = Integer.parseInt(read.readLine());
    int no_temp,product=1,sum=0;
    int r;
    no_temp = no;
    // calculate sum and product of the number here.
    while(no>0)
    {
    r=no%10;
    sum=sum+r;
    product=product*r;
    no=no/10;
    }
    // compare the sum and product.
    if(sum==product)
    System.out.println("Given number is a spy number");
    else
    System.out.println("Given number is not a spy number");
    }
    }
    

    Question 6

    Marks [15]

    Using switch statement, write a menu driven program for the following:

    1. To find and display the sum of the series given below:
      S = x1-x2+x3-x4+x5 ……………. –x20
    2. (where x = 2)

    3. To display the following series: 1 11 111 1111 11111
      For an incorrect option, an appropriate error message should be displayed.

    Ans.

    import java.io.*;
    public class SeriesMenu
    {
    public static void main(String args[])throws IOException
    {
    BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
    System.out.println("Menu for choice:-");
    System.out.println("1. Sum of series S = x1-x2+x3-x4....x20");
    System.out.println("2. Display Series 11 111 1111 11111");
    System.out.print("Enter your Choice: ");
    int cho = Integer.parseInt(read.readLine());
    double sum=0;
    switch(cho)
    {
    case 1:
    int x=2;
    for(int i=1;i<=20;i++)
    {
    if(i%2==0)
    sum = sum - Math.pow(x,i);
    else
    sum = sum + Math.pow(x,i);
    }
    System.out.println("S = "+sum);
    break;
    case 2:
    int d=1,s1=0;
    for(int i=1;i<=5;i++)
    {
    s1=s1*10+d;
    System.out.print(s1 +"\t");
    }
    break;
    default:
    System.out.println("Invalid Input for your choice - Try again");
    }
    }
    }
    

    Question 7

    Marks [15]

    Write a program to input integer elements into an array of size 20 and perform the following operations:

    1. Display largest number from the array.
    2. Display smallest number from the array.
    3. Display sum of all the elements of the array.

    Ans.

    import java.io.*;
    public class ArrayOperations
    {
    public static void main(String args[])throws IOException
    {
    BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
    int i;
    int as = 20; // Scope of array
    int[] numbers = new int[as];
    System.out.println("Enter 20 numbers one by one: ");
    for (i = 0; i < as; i++)
    {
    System.out.print("Enter number for " +(i+1) +": ");
    numbers[i] = Integer.parseInt(read.readLine());
    }
    int largest = numbers[0];
    int smallest = numbers[0];
    int sum = 0;
    for (i = 0; i < as; i++)
    {
    if (numbers[i] < smallest)
    {
    smallest = numbers[i];
    }
    if (numbers[i] > largest)
    {
    largest = numbers[i];
    }
    sum = sum + numbers[i];
    }
    System.out.println("Largest No ="+largest);
    System.out.println("Smallest No ="+smallest);
    System.out.println("Sum of all elements="+sum);
    }
    }	
    

    Question 8

    Marks [15]

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

    1. void check(String str, char ch) – to find and print the frequency of a character in a string.
      Example:
      Input Output
      Str= “success” number of s present is=3
      ch= ‘s’
    2. void check (String s1) – to display only the vowels from string s1, after converting it to lower case.
      Example:
      Input:
      S1= “computer” output: o u e

    Ans.

    import java.io.*;
    public class Overload_check
    {
    void check(String str, char ch)
    {
    int frequency = 0;
    char currentChar;
    for (int i = 0; i < str.length(); i++)
    {
    currentChar = str.charAt(i);
    if (ch == currentChar)
    {
    frequency++;
    }
    }
    System.out.println("Number of " +ch +" present is " +frequency);
    }
    void check(String str)
    {
    str = str.toLowerCase();
    char currentChar;
    System.out.print("Vowel(s) that is/are present in the given string: " );
    for (int i = 0; i < str.length(); i++)
    {
    currentChar = str.charAt(i);
    if (currentChar == 'a' || currentChar == 'e' || currentChar == 'i' || currentChar == 'o' || currentChar == 'u')
    {
    System.out.print(currentChar +" " );
    }
    }
    }    
    public static void main(String args[])throws IOException
    {
    BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
    String sr;
    char ch;
    System.out.print("Enter any string: ");
    sr=read.readLine();
    System.out.print("Enter any char: ");
    ch=(char)read.read();
    Overload_check obj = new Overload_check();
    obj.check(sr,ch);
    obj.check(sr);
    }
    }
    

    Question 9

    Marks [15]

    Write a program to input forty words in an array. Arrange these words in descending order of alphabets, using selection sort technique. Print the sorted array.

    Ans.

    import java.io.*;
    public class SelectionSortOfWord
    {
    public static void main(String args[]) throws IOException
    {
    BufferedReader read=new BufferedReader(new InputStreamReader(System.in));
    int max = 4;
    int i,j;
    String[] words = new String[max];
    String str;
    // Accept 40 words in an array
    System.out.println("Enter words: ");
    for (i = 0; i < max; i++)
    {
    System.out.println("Enter words for " +(i+1) +": ");
    words[i] = read.readLine( );
    //First char to upper case + Rest of the Character (as sorting is case sensetive)
    str = words[i];
    str = str.substring(0,1).toUpperCase() + str.substring(1); 
    //or instead//str = Character.toUpperCase(str.charAt(0)) + str.substring(1);
    words[i] = str;
    }
    max = words.length;
    String temp;
    //Sort using selection sort
    for (i = 0; i < max; i++)
    {
    for (j = i + 1; j < max; j++)
    {
    if (words[i].compareTo(words[j])<0)
    {
    temp = words[i];
    words[i] = words[j];
    words[j] = temp;
    }
    }
    }
    //Print sorted array in desending order
    System.out.println("Words in Sorted Order:");
    for (i = 0; i < max; i++)
    {
    System.out.println(words[i]);
    }
    }
    }
    

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.