ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

Max Marks: 80
[2 Hours]

General Instructions

  • Answers 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 at the head of this Paper is the time allowed for writing the answers. O This Paper is divided into two Sections.
  • Attempt all questions from Section A and any four questions from Section B.
  • The intended marks for questions or parts of questions are given in brackets [ ].

SECTION – A [40 Marks]
Attempt All Question

Question 1.
(a) (i) Name the keyword that makes the variable constant in a program.
Answer:
final

(ii) Name the keyword that makes the system to report an error.
Answer:
throws

a. Differentiate between equals() and equalslgnoreCase()
Answer:

equals() equalslgnoreCase()
Compare two strings character by character.
Eq: String si = “lol”, s2 = “lol1”; System.out.print(s1.equals(s2));
Compares two strings ignoring the case of the letters.
Eg: String s1 = “lol”,s2=”lol”;
System.out.print(s1. equalslgnoreCase(s2);

b. What is the use of access specifier. Name any two.
Answer:
Access specifiers are used to limit the visibility of data according to the users choice.
Eg. private, public.

c. String s1 = “computer” , s2 =”computers”; System.out.
printIn(s1.compareTo(s2);
Answer:
-1

d. Differentiate between linear search and binary search.
Answer:

Linear Search Binary Search
One by one search element is compared with all elements of the array. The array is sorted and then divided into two halves and then search element is compared to the middle element of the array, if its greater than middle element then search is to be done in upper halves and its its lesser than middle element search to be done in lower halves.
The array need not to be sorted. The array must be sorted.

Question 2.
(a) Write the memory occupied in computer in bytes for array a[5] of character data type.
Answer:
10 bytes 24 bytes

(b) Differentiate between length() and length functions.
Answer:

Length() Length
The method is applicable for finding the length of string. This is used for finding the array length.

(c) What is error? How logical error differ from syntax error?
Answer:
When there is an improper use of statement or statement is logically incorrect then an error is displayed.
Syntax error is displayed when there is improper use of basic java statements.
Logical error is displayed when statement is not giving correct output after execution.

(d) Name the methods of scanner class that:
(i) Is used to input an integer data from standard input stream.
Answer:
nextInt()

(ii) Is used to input a string data from standard input stream.
Answer:
nextLine() or next()

(e) Write the statement to perform the following task:
(i) To find and display the position of the first space in the string str
Answer:
System.out.printIn(“COMP IS FUN”.indexOf(”));

(ii) To find and display the position of the last space in string str.
Answer:
System.out.printIn(“COMP IS FUN”.lastindexOf(”));

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

Question 3.
(a) The arguments of the function given in the function definition are called
Answer:
formal parameters

(b) Why JVM is required for running java program. Justify your answer.
Answer:
JVM is used to convert the byte code into machine language which can be run on any machine. In java, the compiler produces machine code for a particular system. Java compiler produces code for a Virtual Machine known as Java Virtual Machine.

(c) Attempt the following:
(i) What is called type casting in java. Explain with example.
Answer:
The conversion of data from one data type to another datatype is called typecasting.
Eg. char ch =’A’;
Int ch 1 = ch;

(ii) Write all the possible correct syntaxes of declaring array.
Answer:
int a[ ] = new int [10];
int a[ ];
int a[] = {1,2,3};

(iii) What is the purpose of new operator. Why is it useful?
Answer:
The purpose of new operator is to allocate memory to the object. It is helpful in the creation of new object.

(iv) double as =Math.pow(“214”.indexOf(‘4’,3));
Answer:
8.0

(v) char a[ ] = {‘j’/a’/v’/a’}; int c = 1;
System.out.pritnln(a[++c]);
System.out.pritnln(a[c]++);
Answer:
(i) v
(ii) a

(vi) Explain the use of return statement in the java.
Answer:
It is the keyword in java to return from the method with value or without value.

(vii) State the purpose and return data type of the following String functions:
(i) indexOf()
(ii) compareTo()
Answer:
(i) Find the index of a character return type is integer.
(ii) Compares two strings return type is integer.

(viii) State the output of the code:
int m = 25; int n = 100;
for(int 1 = 1; i<5; i++); m++; -n;
System.out.printIn(“m=”+m);
System.out.printIn(“n=”+n);
Answer:
m=20, n=9

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 descripticns/Mnemonic Codes such that the logic of the program is clearly depicted.

Flow-Charts and Algorithms are not required.

Question 4.
Write a program to accept the word from user and print the pattern as shown below:
Sample Input: COMP
Output:
C
CO
COM
COMP
COM
CO
C
Answer:

import java.util.*;
class lol
{
public static void main()
{
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a word");
String str = sc.next();
for(int i =0; i<str.length(); i++)
{
for(int j =0; j<=i;j++)
{
charch = str.charAt(i);
System.out.print(ch+" ");
}
System.out.printInO;
}
for(int i = str.length()ā€”2; i<=0; iā€”)
{
for(int j = 0; j<=i; jā€”)
{
char ch = str.charAt(j);
System.out.print(ch+"");
}
System.out.printIn();
}
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

Question 5.
Write a program to accept the 15 names in the array and arrange them in alphabetical order by bubble sort technique only. And print the output list.
Answer:

import java.util.*;
class lol
{
public static void main()
{
String temp;
String a[ ] = new Stringfl 5];
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a 15 names");
for(int i =0; ka.length; i++)
{
a[i] =sc.nextLine();
}
forfint i = 0; i<a.length; i++)
{
for(int j =0; j<a.length-i-1; j++)
{
if(a[j].compareTo(a[j++])>0)
{
temp = a[j];
a[j]=a[j+1];
a[j+1] = temp;
}
}
}
for(int i =0;
ka.length; i++)
{
System.out.printIn(a[i]);
}
}//end of main
}//end of class

Question 6.
Write a program to accept sentence from user and print number of words which starts with vowel and ends with vowel.
Input: india is greatest country
Output: 1
Answer:

import java.util.*;
class lol
{
public static void main()
{
int count =0;
Scanner sc = new Scanner(System.in);
System.out.priintIn("Enter a sentence:");
String str = sc.nextLine(), word ="";
for(int i =0; i<str.length(); i++)
{
char ch = str.charAt(i);
if(ch!='')
word = word + ch;
else
{
char ch1 =word.charAt(0);
char ch2 = word.charAt(word.length()-1);
if((ch1=='a' || ch1=='A' || ch1 == 'e'|| ch1 == 'E' || chi =='i'||ch1 ==T|| ch1=='u'||ch1=='Uj|ch1=='o'||ch1=='O')&&(ch2=='a' || ch2=='A' || ch2
== 'e'|| ch2 == 'E' || ch2=='i'||ch2=='l'||ch2=='u'||ch2=='U'||ch2= 'o'|| ch2=='O'))
{
count++;
}
word
}
}
System.out.printIn(count);
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

Question 7.
Write a program to arrange the words in sentence given by user in alphabetical order. Assume input is in lower case letters only.
Input: india is my country
Output: country india is my
Answer:

import java.util.*;
class lot
{
public static void main()
{'
int count =0;
Scanner sc = new Scanner(System.in);
System.out.printIn("Enter a sentence:");
String str = sc.nextLine(), word = " ";
str = str+" ";
forfint i =0; i<str.length(); i++)
{
char ch= str.charAt(i);
if(ch =='')
count++;
}
String a[ ] = new String[count];
String temp;
forfint i =0; i<str.length(); i++)
{
char ch = str.charAt(i);
if(ch!='') word+= ch;
else
{
int j = 0;
a[j]=word;
word =" ";
j++;
}
}
for(int i =0; i<a.length; i++)
{
for(int j =0;j<a.length-i-1; j++)
{
if(a[j].compareTo(a[j+1 ])>0)
{
temp = a[i];
a[j] = a[j+1];
a[j+1] = temp;
}
}
}
for(int j =0; j<a. length; j++)
{
System.out.print(a[j]+" ");
}
}//end of main
}//end of class:

Question 8.
Write a program to accept integer values in the array and find the second lowest value from the array without sorting the array.
inta[] = {3.10.4,8,12,6,23}
Output: 4
Answer:

import java.util.*;
class lol
{
public static void main()
{
int count =0;
int sum = 0;
Scanner sc = new Scanner(System.in);
int a[] = new int[10];
System.out.printIn("Enter 10 values:");
for(int i =0; ka.length; i++)
{
a[i] = sc.nextInt();
}
int low=0;
int secondlow=low;
for(int i =0; i<a.length; i++)
{
if(low >a[i])
{
secondlow=low;
low = a[i];
}
}
System.out.printIn(secondlow);
}//end of main
}//end of class

ICSE Class 10 Computer Application Sample Question Paper 7 with Answers

Question 9.
Write a function to display the given pattern: void pattern (int n)
Note: n is the number of rows:
ICSE Class 10 Computer Application Sample Question Paper 7 with Answers 1
Answer:

import java.util.*;
class lol
{
public void pattern(int n)
{
int n = 5;
int I = 0;
for(int i =1; i<=n; i++)
{
int k = 1;
for(int j = 1; j<=i; j++)
{
System.out.print(k+" ");
k+=2;
}
int l1 = l;
for(int j = 2;j<=i;j++)
{
System.out.print(l1+" ");
l1 ++;
}
l+=2;
System.out.printIn();
}
}//end of function pattern
}//end of class
Variable Data type Description
sc Scanner Object for reading data from input stream.
str String Store word from user
ij int For looping
ch char To reach one character from word.
a[ ] String String array for storng 15 names.
temp String Storing temporary strings.
count int For counting the vowels
word String Temporary for storing string
low secondlow int Store lowest value and store second lowest value.

ICSE Class 10 Computer Application Question Papers with Answers

Leave a Comment