ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

Maximum Marks: 50
Time: 2 Hours

Section – A [10 Marks]
Attempt all questions

Question 1.
Choose the correct answers to the questions from the given options. (Do not copy the question, write the correct answer only)
(i) Each primitive data type belongs to a specific:
(a) block
(b) object
(c) wrapper class
(d) none of these
Answer:
(c) Wrapper class
Explanation:
Each primitive data type has a canvas of wrapper class. The wrapper classes have associated functions to deal with the associated data types.

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

(ii) The process of restricting the free flow of data from the outside world is known as:
(a) Encapsulation
(b) Inheritance
(c) Function
(d) Class
Answer:
(a) Encapsulation
Explanation:
The OOPs feature Encapsulation encapsulates data and functions of a class as one unit and shields them from the outside world.

(iii) Given array int x[] = {11, 22, 33, 44); the value of x[l+2] is .
(a) 11
(b) 22
(c) 33
(d) 44
Answer:
(d) 44
Explanation:
x[1+2] means x[3], here x[3] is 44

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

(iv) Which of these is a wrapper for simple data type boolean?
(a) Bool
(b) Boolean
(c) True
(d) False
Answer:
(b) Boolean
Explanation:
Boolean is the wrapper class for the Boolean primitive data type.

(v) Which of the following methods checks that a string starts with a particular string or not?
(a) Starts()
(b) Startswith()
(c) startsWith()
(d) StartsWith()
Answer:
(c) startsWith()
Explanation:
The startsWith() function checks whether a string begins with a particular string or not and returns a boolean true or false.

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

(vi) Given a string str=”Publicaccess”;
To display the 3rd and 4th characters in uppercase the statement will be :
(a) System.out.println(str.substring(2,4).toUpperCase());
(b) System.out.println(str.substring(2,3).toUpperCase());
(c) System.out.println(str.substring(2).toUpperCase());
(d) System.out.println(str.substring(2,4).touppercase());
Answer:
(a) System.out.println(str.substring(2,4).toUpperCase());
Explanation:
The substring(2,4) extracts characters from index 2 to 3 and toUpperCase() converts them to uppercase

(vii) To make accessibility to own class, classes of same package and child classes the access specifier should be:
(a) Private
(b) Public
(c) Protected
(d) Default
Answer:
(c) Protected
Explanation:
The protected access specifier can be used to make accessibility to own class, classes of same package and child classes.

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

(viii) Given a string trn=”HimgiriExpress”, the statement that will show “EXPRESS” from the string will be:
(a) tm.right(4)
(b) tm.substring(7)
(c) tm.substring(7).toUpperCase()
(d) tm.right(7,16). toUpperCase()
Answer:
(c) trn.substring(7).toUpperCase()
Explanation:
The tm.substring(7) returns the characters from index 7 to the end of the string i.e : ‘Express’ and the toUpperCase() function converts it to uppercase to return ‘EXPRESS’.

(ix) The output of the following code is :
public class myclass
{
public static void main(String []args)
{
String si = new String(“Ram”);
String s2 = new String(“Laxman”);
System.out.println(sl = s2);
}
}
(a) Ram
(b) Laxman
(c) RamLaxman
(d) False
Answer:
(b) Laxman
Explanation:
s1 = s2 assigns s2 to si, which is then printed.

Section – B  (40 Marks)
Attempt any four questions

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 descriptions/Mnemonic Codes such that the logic of the program is clearly depicted. Flow-Charts and Algorithms are not required.

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

Question 2.
Define a class with an integer array to store 6 integers and a main function to accept 6 numbers in the array and swap the adjacent elements.
Answer:
Example:

Input: Enter 6 numbers: 10 20 30 40 50 60
Output: After swap list are: 20 10 40 30 60 50
import java.util.Scanner;
class SwapNums
{
public static void main(String args[])
int i, t;
int arr[] = new int[6];
Scanner sc = new Scanner(System.in);
System.out.print("Enter 6 numbers:");
for (i = 0; i < 6; i++)
{
arr[i] = sc.nextlnt();
}
i = 0;
while (i < 6 -1)
{
t = arr[i];
arr[i] = arr[i + 1];
arr[i + 1] = t;
i = i + 2;
}
System.out.print("After swap list are:");
for (i = 0; i < 6; i++)
{
System.out.print(" " + arr[i]);
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

Question 3.
Given the specification of the following class Student.
Class name: Student Data members
Roll integer
Name String
Termlmarks float
Term2marks float
Perc float
Member functions
getStudent() – To input student roll, name and marks in 2 terms and calculate percentage (Formula : Perc=(Terml+Term2)/2)
showStudent() – To display student name and percentage.
Define the class as per the specification.
Answer:

class Student
{
int roll;
String name;
float termlmarks;
float term2marks;
float perc;
public void getStudent()
{
Scanner sc=new Scanner(System.in);
roll=sc.nextInt();
name=sc.nextLine();
termlmarks=sc. nextFloat();
term2marks= sc. nextFloat();
perc=(termlmarks + term2marks)/2;
}
public void showStudent()
{
System.out.println("Name :"+ name)
System.out.println("Percentage:"+perc);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

Question 4.
Define a class to input a sentence and display the words that are palindromes. A palindrome is a word that is same as its reverse.
Answer:

import java.util.Scanner;
public class PalinWords
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a sentence:");
String str = in.nextLine();
str = str + "
String word = "
int len = str.length();
for (int i = 0; i < len; i++)
{
char ch = str.charAt(i);
if (ch ='')
{
int wordLen = word.length();
boolean isPalin = true;
for (int j = 0; j < wordLen / 2; j++)
{
if (word.charAt(j) != word.charAt(wordLen -1 - j))
{
isPalin = false;
break;
}
}
if (isPalin)
System.out.println(word);
word ="";
}
else
{
word += ch;
}
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

Question 5.
Define a class to accept 10 strings and a search string. Search for the string and display whether found or not. If not found, display proper message.
Answer:

import java.util.*;
class search
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
String [] str= new String[10];
int flag=0,i;
System.out.println("Enter 10 strings:");
for(i=0;i<10;i++)
str[i] = sc.nextLine();
System.out.println("Enter the name to search
String s=sc.nextLine();
for(i=0;i<10;i++)
{
if(s=stri])
{
flag=l;
break;
}
}
if(flag=l)
System.out.println("The name "+s+" Exists");
else
System.out.println("The name "+s+" does not Exist");
}
}

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

Question 6.
Define a class in java to input a sentence and a word and check whether the word is present in the sentence or not.
Answer:

import java.util.Scanner;
public class check_words
{
public static void main(String[] args)
{
String sentence;
String word;
String w = "";
int len, i, f = 0;
Scanner obj= new Scanner(System.in);
System.out.println("Enter the sentence: "); // enter the sentence
sentence = obj.nextLine();
sentence = sentence + " ";
len = sentence.length();
System.out.println("Enter the word to be searched:"); // enter the word
word = obj.nextLine();
word = word.trim();
for(i=0;i<len;i++)
{
if(sentence.charAt(i)!='')
{
w = w + sentence.charAt(i); // to seperate each word
}
else
{
if(w.equals(word)){ // check whether the word is the input word
System.out.println(w+ "is contained in a sentence");
f=l;
break;
}
w=""; // to reset w to ""
}
if(f==0)
System.out.println(word+ "is not contained in a sentence");
}
}

ICSE Class 10 Computer Applications Sample Question Paper 15 with Answers

Question 7.
Defne a class in Java to accept a String/Sentence and display the smallest and longest words present in the String.
Sample Input: “Rahul Dravid is a consistent player”
Sample Output: The longest word: Consistent
The smallest word: is
Answer:

import java.util.*;
class FindMinMaxString {
public static void main(String args[])
{
String sen;
Scanner sc = new Scanner(System.in);
System.out.println("Enter sentence :");'
sen=sc.nextLine();
findMethod(sen);
}
static public void findMethod(String s)
{
String str = s + " ";
char ch = ";
int len = str.length(), 1 = 0;
int min = len, max = 0;
String sword = lword = word = "";
for (int i = 0; i < len; i++)
ch = str.charAt(i);
if (ch !='')
{
word += ch;
}
//if ends
else
{
1 = word.length();
if (1 < min) { min = 1; sword = word; } //if ends if (1 > max)
{
max = 1; lword = word;
}
word ="";
}
System.out.println("Shortest word = " + sword + " with length " + min);
System.out.println("Longest word = " + lword + " with length " + max);
}
}
ICSE Class 10 Computer Applications Question Papers with Answers

Leave a Comment