ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

ICSE Class 10 Computer Applications Sample Question Paper 14 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) Which of these is a super class of wrappers Long, Character and Integer?
(a) Long
(b) Digits
(c) Float
(d) Number
Answer:
(d) Number
Explanation:
Number is an abstract class containing subclasses Double, Float, Byte, Short, Integer and Long.

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

(ii) Which of the following statements are incorrect?
(a) String is a class
(b) Strings in java are mutable
(c) Every string is an object of class String
(d) Java defines a peer class of String, called StringBuffer, which allows string to be altered
Answer:
(b) Strings in java are mutable
Explanation:
Strings in Java are immutable that is they can not be modified.

(iii) What will be the output of the following Java program? class string _Term2
{
public static void main(String args[])
{
String obj = “I” + “like” + “Java”;
System.out.println(obj);
}
}
(a) I
(b) like
(c) Java
(d) IIikejava
Answer:
(d) Ilikejava
Explanation:
Java defines an operator +, it is used to concatenate strings.

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

(iv) Which of these is a wrapper for simple data type char?
(a) Float
(b) Character
(c) String
(d) Integer
Answer:
(b) Character
Explanation:
In Java Character is wrapper class for char type.

(v) Non static functions can access:
(a) Static data members
(c) Both (a) and (b)
(b) Non static data members
(d) None of these
Answer:
(c) Both (a) and (b)
Explanation:
In java, non static functions can access both static data members and non static data members.

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

(vi) Given a string str=”FilmFestiva12021″;
The statement str.substring(4,12).toUpperCase() will produce :
(a) Film
(b) Fest
(c) Festival
(d) FESTIVAL
Answer:
(d) FESTIVAL
Explanation:
str.substring(4,12) returns characters from index 4 to 11, that is “Festival” and toUpperCase() converts it to FESTIVAL.

(vii) Which among the following best describes encapsulation?
(a) It is a way of combining various data members into a single unit.
(b) It is a way of combining various member functions into a single unit.
(c) It is a way of combining various data members and member functions into a single unit which can operate on any data.
(d) It is a way of combining various data members and member functions that operate on those data members into a single unit.
Answer:
(d) Encapsulation
Explanation:
It is a way of combining both data members and member functions, which operate on those data members, into a single unit. We call it a class in OOPs generally.

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

(viii) The most strict access specifier is:
(a) Private
(b) Public
(c) Protected
(d) Default
Answer:
(a) Private
Explanation:
The Private access specifier is most strict as private members can be accessed only in the class where they are defined.

(ix) Consider the following two statements : int x = 25;
Integer y = new Integer(33);
What is the difference between these two statements?
(a) Primitive data types
(b) Primitive data type and an object of a wrapper class
(c) Wrapper class
(d) None of the above
Answer:
(b) Primitive data type and an object of a wrapper class
Explanation:
Here the variable x is of primitive data type. Whereas Integer y is an object of Integer wrapper class.

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

(x) Void is not a wrapper class
(a) True
(b) False
Answer:
(a) True
Explanation:
Unlike the other wrappers Void class doesn’t store a value of type void in itself and hence is not a wrapper in true essence. – The Void class according to javadoc exists because of the fact that some time we may need to represent the void keyword as an object.

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.

Question 2.
Write a program in Java to store 20 temperatures in °F in a Single Dimensional Array (SDA) and display all the temperatures after converting them into °C.
Hint: (c/5) = (f – 32) / 9
Answer:

import java.util.Scanner;
public class Temperature
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
double arr[] = new double[20];
System.out.println("Enter 20 temperatures in degree Fahrenheit");
for (int i = 0; i < arr.length; i++)
{
arr[i] = in.nextDouble();
}
System.out.println("Temperatures in degree Celsius");
for (int i = 0; i < arr.length; i++)
{
double tc = 5 * ((arr[i] - 32) / 9);
System.out.println(tc);
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

Question 3.
Write a program to input a sentence. Find and display the following:
(i) Number of words present in the sentence
(ii) Number of letters present in the sentence
Assume that the sentence has neither include any digit nor a special character.
Answer:

import java.util.Scanner;
public class WordsNLetters
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a sentence:");
String str = in.nextLine();
int wCount = 0, ICount = 0;
int len = str.length();
for (int i = 0; i < len; i++)
{
char ch = str.charAt(i);
if (ch ='') wCount++;
else
lCount++;
}
wCount++;
System.out.println("No. of words = " + wCount);
System.out.println("No. of letters = " + ICount);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

Question 4.
Write a program to accept name and total marks of N number of students in two single subscript arrays name[] and totalmarks[ ]. Calculate and print:
(i) The average of the total marks obtained by N number of students.
[average = (sum of total marks of all the students)/N]
(ii) Deviation of each student’s total marks with the average.
[deviation = total marks of a student – average]
Answer:

import java.util.Scanner;
public class ArrayProcessing
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.print("Enter number of students: ");
int n = in.nextlnt();
String nameQ = new String[n];
int totalmarks[] = new int[n];
int grandTotal = 0;
for (int i = 0; i < n; i++)
{
in.nextLine();
System.out.print("Enter name of student" + (i+1) + ");
name[i] = in.nextLine();
System.out.print("Enter total marks of student " + (i+1) + ");
totalmarks[i] = in.nextlnt();
grandTotal += totalmarks[i];
}
double avg = grandTotal / (double)n;
System.out.println("Average = " + avg);
for (int i = 0; i < n; i++)
{
System.out.println("Deviation for " + name[i] + " = " + (totalmarks[i] - avg));
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

Question 5.
Write a program in Java to accept a name(Containing three words) and Display only the initials (i.e., first letter of each word).
Sample Input: NARAYAN KUMAR DEY
Sample Output: N K D
Answer:

import java.util.Scanner;
public class Namelnitials
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a name of 3 or more words:");
String str = in.nextLine();
int len = str.length();
System.out.print(str.charAt(0) + " ");
for (int i = 1; i < len; i++)
{
char ch = str.charAt(i);
if (ch ='')
{
char ch2 = str.charAt(i + 1);
System.out.print(ch2 + " ");
}
}
}
}

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

Question 6.
Write a program in Java to accept a name containing three words and display the surname first, followed by the first and middle names.
Sample Input: LALA MOHENDAR AMARNATH
Sample Output: AMARNATH LALA MOHENDAR
Answer:

import java.util.Scanner;
public class SurnameFirst
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a name of 3 words:");
String name = in.nextLine();
int lastSpaceldx = name.lastIndexOf('');
String surname = name.substring(lastSpaceIdx + 1);
String initialName = name.substring(0, lastSpaceldx);
System.out.println(sumame + " " + initialName);
}
}

ICSE Class 10 Computer Applications Sample Question Paper 14 with Answers

Question 7.
Write a program in Java to enter a String/Sentence and display the longest word and the length of the longest word present in the String.
Sample Input: “SOURAV GANGULY IS THE PRESIDENT OF BCCI”
Sample Output: The longest word: PRESIDENT: The length of the word: 9
Answer:

import java.util.Scanner;
public class LongestWord
{
public static void main(String args[])
{
Scanner in = new Scanner(System.in);
System.out.println("Enter a word or sentence:");
String str = in.nextLine();
str += " //Add space at end of string
String word = ""; IWord = "";
int len = str.length();
for (int i = 0; i < len; i++) { char ch = str.charAt(i); if (ch ='') { if (word.length() > lWord.length())
IWord = word;
word = "";
}
else
{
word += ch;
}
}
System.out.println("The longest word: " + IWord +
": The length of the word: " + lWord.length());
}
}
ICSE Class 10 Computer Applications Question Papers with Answers

Leave a Comment