Ads

ICSE Solved Paper, 2019

 ICSE Examination 2019 – 20 (Solution) 

COMPUTER APPLICATION 
Class – X 
Section – A (40 Marks) 
Attempt all questions


Question 1: 

a) Name any two basic principles of Object-oriented Programming.    [2] 
Ans: - Abstraction, Encapsulation, Inheritance and Polymorphism (Write any two). 

b) Write a difference between unary and binary operator. [2] 
Ans: - Unary operator works on single operand or variable. Binary operator works on two operands or variables. 

c) Name the keyword which: 
(i) indicates that a method has no return type. 
(ii) makes the variable as a class variable. [2] 
Ans: - (i) void (ii) static 

d) Write the memory capacity (storage size) of short and float data type in bytes. [2] 
Ans: - short – 2 bytes (16 bits),  Float – 4 bytes (32 bits) 

e) Identify and name the following tokens: 
(i) public 
(ii) "a" 
(iii) = = 
(iv) { }   [2] 
Ans: - (i) Keyword or Reserved word 
(ii) Character constant or literal 
(iii) Relational or comparison operator 
(iv) separator or punctuator


Question 2: 

(a) Differentiate between if else if and switch-case statement. [2] 
Ans: - i) if else if allows all relational operators whereas, switch-case allows only = = operator. 
ii) if else if allows all data types whereas switch-case allows int, char and String. 
iii) Range of values are checked in if else if whereas, one value is compared.

(b) Give the output of the following code: 
String P = “20”, Q = “19”; 
int a = Ingeger.parseInt(P); 
int b = Ingeger.parseInt(Q);
System.out.println(a+ “” +b); [2] 
Ans: - 2019

(c) What are the various types of errors in Java? [2] 
Ans: - i) Syntax error / Compiler time error 
ii) Logical error 
iii) Runtime error

(d) State the data type and value of res after the following is executed: 
char ch = "9"; 
res = Character.isDigit(ch); [2] 
Ans: - data type = boolean 
res = true

(e) What is the difference between the linear search and the binary search technique? [2] 
Ans: - Linear Search 
 i) Can work on unsorted array.
ii) Check each item.
iii) Takes more time.
        Binary Search 
i) Array must be sorted.  
ii) Does not check each item.  
iii) Takes less time 


Question 3: 

(a) Write a Java expression for the following:  [2]
Ans: - Math.abs(x*x + 2*x*y) or, Math.abs(Math.pow(x,2) + 2*x*y);

(b) Write the return data type of the following functions: [2] 
(i) startsWith() 
(ii) random() 
Ans: - startsWith() – Boolean 
random() – double 

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

(d) Give the output of the following code and mention how many times the loops will execute? [2]
int i; 
for(i = 5; i>=1; i – –) 

if(i%2 = = 1) 
continue; 
System.out.print(i+ “ ”); 

Ans: - Output: 4 2 
5 times the loop will execute. 

(e) State a difference between call by value and call by reference. [2]

Call by value

Call by reference

i) It works with primitive data type.

i) It works with reference (address) data type.

ii) The original value of variable remains unchanged.

ii) The original value of variable changes.

iii) Operation is performed on duplicate value of variables.

iii) Operation is performed on original values of variables.

iv) It is also called pure function.

iv) It is also called as impure function.

(f) Give the output of the following: [2] 
Math.sqrt(Math.max(9, 16)) 
Ans: - 4.0 

(g) Write the output for the following: [2] 
String s1 = “phoenix”; 
String s2 = “island”; 
System.out.println(s1.substring(0).concat(s2.substring(2))); 
System.out.println(s2.toUpperCase()); 
Ans: phoenixland 
ISLAND

(h) Evaluate the following expression if the value of x =2, y = 3 and z = 1. [2]
v = x+ – –z+ y++ +y; 
Ans: v = 2 + 0 + 3 + 4 = 9 

(i) String x[] = {“Artificial intelligence”, “IOT”, “Machine learning”, “Big data”}; [2] 
Give the output of the following statements: 
(i) System.out.println(x[3]); 
(ii) System.out.println(x.length); 
Ans: - i) Big Data 
ii) 4 

(j) What is meant by a package? Give an example. [2]
Ans: - Package is a group of related classes. Example: java.io, java.util, etc.



Section – B (60 Marks) 
Attempt any four questions 

Question 4:

Design a class name 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
         Members 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 following criteria:

Cost

Discount (in percentage)

Less than or equal to ₹ 10000

5%

More than ₹ 10000 and less than or equal to ₹ 20000

10%

More than ₹ 20000 and less than or equal to ₹ 35000

15%

More than ₹ 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. [15]

Ans:import java.util.*; 
class ShowRoom 
{
 String name; 
long mobno; 
double cost, dis, amount; 
ShowRoom() 
name = “”; 
cost = 0; 
mobno = 0; 
dis = 0.0; 
amount = 0.0; 
}
void input() 
Scanner sc = new Scanner(System.in); 
System.out.println(“Enter name, mobile no and cost”); 
name = sc.next(); 
mobno = sc.nextLong(); 
cost = sc.nextDounle(); 
void calculate() 
if(cost<=10000) 
dis=0.05*cost; 
else if(cost <= 20000) 
dis = 0.1 * cost; 
else if(cost <= 35000) 
dis = 0.15 * cost; 
else 
dis = 0.2 * cost; 
void display() 
System.out.println(“Name is:”+name); 
System.out.println(“Mobile no is:”+mobno); 
System.out.println(“Amount is:”+amount); 
public static void main() 
ShowRoom ob = new ShowRoom(); 
ob.input(); 
ob.calculate(); 
ob.display(); 

Question 5:

Using the switch-case statement, write a menu driven program to do the following: [15]
(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 2 
1 2 3 
1 2 3 4 
1 2 3 4 5 

Ans: import java.util.*; 
class MenuDriven 
public static void main() 
Scanner sc = new Scanner(System.in); 
int ch, x; 
System.out.println(“1. Unicode of letters”); 
System.out.println(“2. Number pattern”); 
System.out.println(“Enter your choice:”); 
ch = sc.nextInt(); 
switch(ch) 
case 1: 
System.out.println(“Letters” + “\t” + “Unicode”); 
for(char c=‟A‟; c<= „Z‟; c++) 
x=c; 
System.out.println(c+ “\t” + x); 
break; 
case 2: 
for(int i =1; i<=5; i++) 
for(j = 1; j<=i; j++) 
    System.out.print(j+ “\t”); 
System.out.println(); 
break; 
default: 
System.out.println(“Wrong choice!”); 
}

Question 6: 

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

Ans: import java.util.*;
class BubbleSort
{
public static void main()
{
    Scanner sc = new Scnanner(System.in);
    int a[] = new int[15];
    System.out.println(“Enter elements”);
    for(int i = 0; i<15; i++) // OR i<a.length
    a[i] = sc.nextInt();
    int temp;
    for(int i = 0; i<a.length – 1; i++) //OR i<14
    {
        for(int j=0; j<(a.length – 1) – i; j++) // OR j<14 – i
        {
            if(a[j] > a[j+1])
            {
                temp = a[j];
                a[j] = a[j+1];
                a[j+1] = temp;
            }
        }
    }
    for(int k = 0; k<a.length; k++) // OR k<15
    System.out.println(a[k]);
    }
}

Question 7:

Design a class to overload a function series() as follows: [15] 
(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:

Ans: class Overload 
{
    void series (int x, int n) 
    
        double sum = 0.0; 
        for (int i = 1; i<=n; i++) 
            sum = sum + Math.pow(x,i); 
        System.out.println(sum); 
    
    void series (int p) 
    
        for (int i = 1; i<=p; i++) 
            System.out.print((i*i*i) – 1 + “ ”); 
    
    void series ()    
    
        double sum = 0.0; 
        for (int i = 2; i<=10; i++) 
            sum = sum + (double)1/i; 
        System.out.println(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 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. [15] 

Ans: - 
class Starting_Letter_A 
     public static void main(String s) 
    
        int c=0,i; 
        char ch1,ch2;
        int l=s.length(); 
        s=s.toUpperCase();
        s=" "+s;
        for(i=0; i<l; i++)
        {
            ch1=s.charAt(i);
            ch2=s.charAt(i+1);
            if(ch1==' ' && ch2=='A') 
                c++;
        }
        System.out.println("Number of of wrods started with letter A: "+c);
    
}

Question 9:

A 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. [15]
Example: 
Consider the number 3025 
Square of sum of the halves of 3025 

Ans:
class TechNumber 
    public static void main() 
    
        int x, r, q, sq, s; 
        for (x = 1000; x<=9999; x++) 
        
            r=x%100; 
            q=x/100; 
            s=r+q; 
            sq=s*s; 
            if(x = = sq) 
                System.out.println(x); 
        
    }
}
SHARE

Author

Hi, Its me Hafeez. A webdesigner, blogspot developer and UI/UX Designer. I am a certified Themeforest top Author and Front-End Developer. I'am business speaker, marketer, Blogger and Javascript Programmer.

  • Image
  • Image
  • Image
  • Image
  • Image
    Blogger Comment
    Facebook Comment

0 Comments:

Post a Comment