ICSE Class 10 COMPUTER APPLICATIONS previous year paper (2019)
- Categories Sample Papers
COMPUTER APPLICATIONS
SECTION A (40 Marks)
Attempt all questions
Question 1. [2 marks each]
(a) Name any two basic principles of Object-oriented Programming.
(b) Write a difference between unary and binary operator.
(c) Name the keyword which:
(i) indicates that a method has no return type.
(ii) makes the variable as a class variable.
(d) Write the memory capacity (storage size) of short and float data type in bytes.
(e) Identify and name the following tokens:
(i) public
(ii) ‘a’
(iii) ==
(iv) { }
Ans.
(a) Encapsulation, Data Abstraction, Polymorphism, Inheritance.
(b)
Unary operator | Binary operator |
---|---|
It works /Performs on single operand or variables. OR Holds only one operand | It works/performs on two variables or operands. OR Holds more than one operand |
(c) (i) void
(ii) static
(d) short – 2 bytes
float – 4 bytes
(e) (i) Keyword
(ii) character literal /constants
(iii) operator
(iv) separator/punctuator
Question 2. [2 marks each]
(a)Differentiate between if else if and switch-case statements.
(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);
(c) What are the various types of errors in Java?
Choose the correct option for the output of the above statements
(i) BEST OF LUCK
(ii) BEST
OF LUCK
(d) State the data type and value of res after the following is executed:
char ch = ‘9’;
res= Character.isDigit(ch);
(e) What is the difference between the linear search and the binary search technique?
Ans.
(a)
If else | Switch |
---|---|
Can compare with range of values | Can set condition to compare a variable with value |
Can be used for floating type nos | Cannot be used for floating point nos |
Can compare 2 variable values | Can compare a variable with constant only |
Logical expressions can be used | Logical expressions cannot be used |
(b) 2019
(c) Syntax error
Logical error
Runtime error
(d) (i) boolean
(ii) true
(e)
Linear Search | Linear Search |
---|---|
Data can be in any order | Data has to be sorted |
It is not efficient | It is more efficient |
Multi-dimensional array can be used. | Works only on single dimensional array |
For large arrays time required is very large. | For large arrays the time required is very less |
Insertion is easy in unsorted arrays | Insertion is comparatively difficult in Binary array. |
Question 3. [2 marks each]
(a) Write a Java expression for the following:
| x²+2xy |
(b) Write the return data type of the following functions:
(i) startsWith( )
(ii) random( )
(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;
(d) Give the output of 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+ '' '');
}
(e) State a difference between call by value and call by reference.
(f) Give the output of the following:
Math.sqrt(Math.max(9,16))
(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());
(h) Evaluate the following expression if the value of x=2, y=3 and z=1.
v=x+ –z+ y++ +y
(i) String x[] = {“Artificial intelligence”, “IOT”, “Machine learning”, “Big data”};
Give the output of the following statements:
(i) System.out.println(x[3]);
(ii) System.out.println(x.length);
(j) What is meant by a package? Give an example.
Ans.
(a) Math.abs(x*x +2*x*y)
Math.abs(Math.pow(x,2)+ 2*x*y)
(b) (i) boolean
(ii) double
(c) tax = 200
(d) 4 2
five times loop will execute
(e)
Call By Value | Call by Reference |
---|---|
Works with immutable type (int, float, String, Tuple) | Works with mutable type (list, dictionary) |
When mutable types are passed then if the value is copied in formal parameters | When immutable types are passed then the reference of the value is passed |
Any change in formal parameters does not change the actual parameter in the main function | If any change is done inside the function, then the value in the main program is changed. |
e.g. def power (n): n = n**2 a = 4 power(a) print (a) // This will print 4 only | def power (n): n[1] = n[0]**2 a = [4,0] power(a) print (a) // This will print [4,16] |
(f) 4.0
(g) phoenixland
ISLAND
(h) v = 9
(i) (i) Big data
(ii) 4
(j) Package in Java is a mechanism to encapsulate a group of classes, sub packages and interfaces
Example: java.lang
java.util
java.io
SECTION B (60 Marks)
Attempt any four questions from this Section
Question 4. [15 marks]
Design a class name ShowRoom with the following description:
class | ShowRoom |
---|---|
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 given criteria |
Void display () | To display customer name, mobile number , amount to be paid after discount. |
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%
Write a main method to create an object of the class and call the above member methods.
Ans.
import java.util.*;
class ShowRoom
{
String name;
long mobno;
double cost;
double dis;
double 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.nextDouble();
}
void calculate()
{
if(cost <=10000)
{
dis=0.05*cost;
}
else if(cost >10000 && cost <=20000)
{
dis=0.1*cost;
}
else if(cost >20000 && cost <=35000)
{
dis=0.15*cost;
}
else
{
dis=0.2*cost;
}
amount = cost - dis;
}
void display()
{
System.out.println("Name is :"+name);
System.out.println("Mobile no is :"+mobno);
System.out.println("Amount :"+ amount);
}
public static void main (String arg[])
{
ShowRoom ob =new ShowRoom();
ob.input();
ob.calculate();
ob.display();
}
}
Question 5. [15 marks]
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
Ans.
import java.util.*;
class menu
{
public static void main (String args[])
{
Scanner obj = new Scanner (System.in);
int choice,x;
System.out.println(" enter 1 for unicode of letters, 2 Pattern");
choice = obj.nextInt();
switch(choice)
{
case 1: System.out.println(" Letters "+ “ " + " Unicode");
for (char c='A'; c<='Z'; c++)
{
x=c;
System.out.println( c +" "+ x);
}
break;
case 2:
for (int i=1; i<=5;i++)
{
for (int j=1; j<=i; j++ )
{
System.out.print(j+" ");
}
System.out.println();
}
}
}
}
Question 6. [15 marks]
Write a program to input 15 integer elements in an array and sort them in ascending order using the bubble sort technique.
Ans.
import java.util.*;
class Bubble
{
public static void main(String[]args)
{
Scanner abc = new Scanner (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]=abc.nextInt();
}//end of for
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;
}
}
}
}
}
Question 7. [15 marks]
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:
x¹ + x² + x³ + ….x^n 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
Ans.
class Overload
{
public static 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);
}
public static void series (int p)
{
for (int i=1; i<=p; i++)
System.out.println((i*i*i)-1);
}
public static void series ()
{
double sum=0.0;
for (int i=2; i<=10;i++)
{
sum=sum+(double)1/i;
}
System.out.print("Sum= "+sum);
}//end of function
}
Question 8. [15 marks]
Write a program to input a sentence and convert it into uppercase and count and display the total number of words starting with a 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.
Ans.
import java.util.*;
class loop
{
public static void main (String args[])
{
Scanner sc=new Scanner (System.in);
String str; char ch, ch1; int c=0;
System.out.println("Enter a sentence");
str= sc.nextLine();
str=str.toUpperCase();
int len= str.length();
for (int i=0; i<len-1;i++)
{
ch= str.charAt(i);
ch1=str.charAt(i+1);
if (i==0 && ch=='A')
c++;
else if (ch==' ' && ch1=='A')
c++;
}
System.out.println("Number of words started with letter 'A' ="+c);
}
}
Question 9. [15 marks]
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.
Example:
Consider the number 3025
Square of sum of the halves of 3025 = (30+25)2
= (55)2
= 3025 is a tech number.
Ans.
class Q9
{
public static void main (String args[])
{
int x,i,j,k, n;
for (x=1000; x<=9999; x++)
{
i= x%100;
j= x/100;
n= i+j;
k=n* n;
if(x== k)
System.out.println(x);
}
}
}