Tuesday, March 19, 2019

Class 10 Computer Applications Question Paper - 2019 (Solution)


ICSE 2019 Computer Applications Question Paper Solved
SECTION A (40 Marks)
Question 1
(a) Name any two basic principles of Object-oriented programming.
Encapsulation and Inheritance.

(b) Write a difference between unary and binary operators.
Unary operators work on one operand, whereas binary operators work on two operands.

(c) Name the which:
(i) indicates that a method has no return type.
void

(ii) makes the variable as a class variable.
static

(d) Write the memory capacity (storage size) of short and float data types in bytes.
short occupies 2 bytes.
float occupies 4 bytes.

(e) Identify and name the following tokens:
(i) public
keyword

(ii) ‘a’
constant

(iii) ==
operator
(iv) {}
separator

Question 2
(a) Differentiate between if else if and switch statements.
if else if can test for all types of conditions, whereas switch only tests for equality.

(b) Give the output of the following code:
String p = "20", q = "19";
int a = Integer.parseInt(p);
int b = Integer.valueOf(q);
System.out.println(a + "" + b);

OUTPUT:
2019

(c) What are the various types of errors in Java?
Compile-time error
Runtime error
Logical error

(d) State the data type and value of res after the following is executed:
char ch = '9';
res = Character.isDigit(ch);

boolean

(e) What is the difference between the linear search and the binary search technique?
Linear search can work on both sorted and unsorted lists, whereas binary search can only work on sorted lists.

Question 3
(a) Write a Java expression for the following:
|x2 + 2xy|
Math.abs(x * x + 2 * x * y)

(b) Write the return data type of the following functions:
(i) 
startsWith()
boolean
(ii) 
random()
double

(c) If the value of basic = 1500, what will be the value of tax after the following statement is executed?
tax = basic > 1200 ? 200 : 100;
tax = 200.

(d) Give the output of the following code and mention how many times the loop will execute:
int i;
for(i = 5; i >= 1; i--){
    if(i % 2 == 1)
        continue;
    System.out.print(i + " ");
}

OUTPUT:
4 2
The loop executes 5 times.

(e) State a difference between call by value and call by reference.
Call by value takes place through primitive data types, whereas call by reference takes place through composite data types.

(f) Give the output of the following:
Math.sqrt(Math.max(9, 16))
OUTPUT:
4.0

(g) Write the output for the following:
String s1 = "phoenix";
String s2 = "island";
System.out.println(s1.substring(0).concat(s2.substring(2)));
System.out.println(s2.toUpperCase());

OUTPUT:
phoenixland
ISLAND

(h) Evaluate the following expression if the value of x = 2, y = 3 and z = 1.
v = x + --z + y++ + y;
= 2 + 0 + 3 + 4
= 9
(i) 
String x[] = {"Artificial intelligence", "IOT", "Machine Learning", "Big data"};

Give the output of the following statements:
(i) 
System.out.println(x[3]);
Big data
(ii) 
System.out.println(x.length);
4

(j) What is meant by a package? Give an example.
A package is a collection of related classes and interfaces.
Example: 
java.io

SECTION B (60 Marks)
Question 4
Design a class named ShowRoom with the following description:
Instance variables/data members:
String name: to store the name of the customer.
long mobno: to store the mobile number of the customer.
double cost: to store the cost of the items purchased.
double dis: to store the discount amount.
double amount: to store the amount to be paid after discount.
Member methods:
ShowRoom(): default constructor to initialize data members.
void input(): to input customer name, mobile number, cost.
void calculate(): to calculate discount on the cost of purchased items, based on the following criteria:

Cost
Discount (in percentage)
Less than or equal to Rs. 10000
5%
More than Rs. 10000 and less than or equal to Rs. 20000
10%
More than Rs. 20000 and less than or equal to Rs. 35000
15%
More than Rs. 35000
20%
void display(): to display customer name, mobile number, amount to be paid after discount.
Write a main() method to create an object of the class and call the above member methods.

import java.io.*;
class ShowRoom{
    private String name;
    private long mobno;
    private double cost;
    private double dis;
    private double amount;
    public ShowRoom(){
        name = new String();
        mobno = 0L;
        cost = 0.0;
        dis = 0.0;
        amount = 0.0;
    }
    public void input()throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Customer name: ");
        name = br.readLine();
        System.out.print("Mobile Number: ");
        mobno = Long.parseLong(br.readLine());
        System.out.print("Cost: ");
        cost = Double.parseDouble(br.readLine());
    }
    public void calculate(){
        if(cost <= 10000)
            dis = 5.0;
        else if(cost <= 20000)
            dis = 10.0;
        else if(cost <= 35000)
            dis = 15.0;
        else
            dis = 20.0;
        dis = dis / 100.0 * cost;
        amount = cost - dis;
    }
    public void display(){
        System.out.println("Customer name: " + name);
        System.out.println("Mobile Number: " + mobno);
        System.out.println("Amount: " + amount);
    }
    public static void main(String args[])throws IOException{
        ShowRoom obj = new ShowRoom();
        obj.input();
        obj.calculate();
        obj.display();
    }
}

Question 5
Using the switch-case statement, write a menu-driven program to do the following:
(a) To generate and print letters from A to Z and their Unicode.
Letters    Unicode
A          65
B          66
.          .
.          .
.          .
Z          90
(b) Display the following pattern using iteration (looping) statement:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

import java.io.*;
class Menu{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.println("1. Unicode Values");
        System.out.println("2. Pattern");
        System.out.print("Enter your choice: ");
        int choice = Integer.parseInt(br.readLine());
        switch(choice){
            case 1:
            System.out.println("Letters\tUnicode");
            for(char i = 'A'; i <= 'Z'; i++){
                System.out.println(i + "\t" + (int)i);
            }
            break;
            case 2:
            for(int p = 1; p <= 5; p++){
                for(int q = 1; q <= p; q++){
                    System.out.print(q + " ");
                }
                System.out.println();
            }
            break;
            default:
            System.out.println("Invalid choice!");
        }
    }
}

Question 6
Write a program to input 15 integer elements in an array and sort them in ascending order using the bubble sort technique.

import java.io.*;
class Sort{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int a[] = new int[15];
        System.out.println("Enter 15 integers:");
        for(int i = 0; i < a.length; i++)
            a[i] = Integer.parseInt(br.readLine());
        for(int i = 0; i < a.length; i++){
            for(int j = 0; j < a.length - 1 - i; j++){
                if(a[j] > a[j + 1]){
                    int temp = a[j];
                    a[j] = a[j + 1];
                    a[j + 1] = temp;
                }
            }
        }
        System.out.println("Sorted elements:");
        for(int i = 0; i < a.length; i++)
            System.out.print(a[i] + "\t");
    }
}


Question 7
Design a class to overload a function series() as follows:
(a) 
void series(int x, int n): to display the sum of the series given below:
x1 + x2 + x3 + … + xn terms
(b) 
void series(int p): to display the following series:
0, 7, 26, 63, … p terms.
(c) 
void series(): to display the sum of the series given below:
1/2 + 1/3 + 1/4 + … + 1/10
class Overload{
    public void series(int x, int n){
        long sum = 0L;
        for(int i = 1; i <= n; i++)
            sum += (long)Math.pow(x, i);
        System.out.println("Sum = " + sum);
    }
    public void series(int p){
        for(int i = 1; i <= p; i++){
            int t = (int)Math.pow(i, 3) - 1;
            System.out.print(t + "\t");
        }
    }
    public void series(){
        double sum = 0.0;
        for(int i = 2; i <= 10; i++)
            sum += 1.0 / i;
        System.out.println("Sum = " + sum);
    }
}

Question 8
Write a program to input a sentence and convert it into uppercase and count and display the total number of words starting with the letter ‘A’.
Example:
Sample Input: ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY ARE EVER CHANGING.
Sample Output: Total number of words starting with letter ‘A’ = 4.

import java.io.*;
class Letters{
    public static void main(String args[])throws IOException{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        System.out.print("Enter the sentence: ");
        String s = br.readLine().toUpperCase();
        int count = 0;
        String word = new String();
        for(int i = 0; i < s.length(); i++){
            char ch = s.charAt(i);
            switch(ch){
                case ' ':
                case '.':
                case '?':
                case '!':
                if(word.charAt(0) == 'A')
                    count++;
                word = new String();
                break;
                default:
                word += ch;
            }
        }
        System.out.println("Total number of words starting with letter 'A' = " + count);
    }
}

Question 9
tech number has even number of digits. If the number is split in two equal halves, then the square of sum of these halves is equal to the number itself. Write a program to generate and print all four digits tech numbers.
Example:
Consider the number 3025.
Square of sum of the halves of 3025 = (30 + 25)2
= (55)2
= 3025 is a tech number.

class Tech{
    public static void main(String args[]){
        for(int i = 1000; i <= 9999; i++){
            if(isTech(i))
                System.out.print(i + "\t");
        }
    }
    public static boolean isTech(int n){
        int a = n / 100;
        int b = n % 100;
        int sum = a + b;
        if(n == sum * sum)
            return true;
        return false;
    }
}

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home