0% found this document useful (0 votes)
597 views8 pages

Computer Application - Answer Key

Uploaded by

diyavelani2008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
0% found this document useful (0 votes)
597 views8 pages

Computer Application - Answer Key

Uploaded by

diyavelani2008
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 8

KARNATAKA ICSE SCHOOLS ASSOCIATION

ICSE STD. X Preparatory Examination 2024


Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024


ANSWER KEY________________________________________________

Maximum Marks: 100


Time allowed: Two hours
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.
___________________________________________________________________________
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
(Attempt all questions from this Section.)
Question 1
Choose the correct answers to the questions from the given options.
(Do not copy the question, write the correct answers only.)
i. When a class serves as base class for many derived classes , the situation
is called

a. Polymorphism b. Encapsulation
c. Inheritance d. Abstraction

ii. The expression which uses the && operator is known as


a. Relational b. Logical c. Arithmetic d. Assignment

iii. Precedence of shorthand operator is ___________ than Unary operator


a. Higher b. Lower c. Equal d. Not related

iv. When the object of a wrapper class is assigned to primitive type variable,
the object is automatically converted to the primitive type is called as

a. Unboxing b. Boxing c. Implicit Conversion d. Inheritance

v. How many bytes are allocated for the array a[] if int a [] = new int [4];
a. 40 bytes b. 16 bytes c. 20 bytes d. 32 bytes

vi. The wrapper class of char type is


a. character b. Chracter c. Character d. Char

vii. The output of System.out.print(Math.ceil(Math.min(-4.3,-7.8))); is

a. -7.0 b. -8.0 c. 7 d.6


KARNATAKA ICSE SCHOOLS ASSOCIATION
ICSE STD. X Preparatory Examination 2024
Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024

viii. Which of the following is not a token?

a. Byte code b. identifiers c. literals d. operators

ix. Name the type of error in the following statement

System.out.println(10/0);

a. Syntax error b. Logical error


c. Runtime error d. No error

x. The size of the array a[ ]={ 3,8,2,1,12,11,13} is

a. 6 b. 7 c. 9 d. 8

xi. The output of the given statements is


String a = "Success", b = "Happiness";
boolean h = a.substring(4).equals(b.substring(6));

a. ess b. ness c. true d false

xii. ___________ compiles the Java source code into byte code

a. Virtual machine b. java interpreter


c. JVM compiler d. object code

xiii. The java statement to access the 5th character in the string str is:

a. str.indexOf(i) b. str.charAt(4)
c.str.substring(5) d. str.length()

xiv. A method prototype which has function name display() which takes two
characters as input and an integer number as a return type is

a. void display(int a ,int b) b. int display(int a ,int b)

c. int display(char a ,char b) d. char display(int a ,int b)

xv. The method compareTo() returns __________ when two strings are equal
and in lowercase :
a. true b. 0 c. 1 d. false

xiv. Which of the following is a valid String constant?

a. true b. ‘false’ c. false d.”true”


KARNATAKA ICSE SCHOOLS ASSOCIATION
ICSE STD. X Preparatory Examination 2024
Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024

xvii. The output of the following snippet is


System.out.print("Output is ");
for(int m=5;m<=50;m+=5)
{
if(m%6==0)
continue;
else
if(m%3==0)
System.out.println(m);
}

a. Output is 15 b. 16 35 c. Output is 15
45

d. 45 15

xviii. Assertion (A): A loop that in which there is no statement associated in


its body is called as an infinite loop.
Reason(R) : In the infinite loop the test condition will always be true.
a. Both Assertion (A) and Reason (R) are true and Reason (R) is a correct
explanation of Assertion (A)
b. Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion(A)
c. Assertion (A) is true and Reason (R) is false
d. Assertion (A) is false and Reason (R) is true

xix. Read the following text and choose the correct answer

A constructor is a special member function used to initialise the data


members whenever an object is created for the class. The different types of
constructors are
• Default constructor
• Parameterised constructor

How do we invoke a constructor in the program?

a. We should create a separate method with the return type as void


b. When an object is created the constructor is invoked
c. The method call should be initialsed to a data type.
d. A pure function needs to be created to call the constructor
KARNATAKA ICSE SCHOOLS ASSOCIATION
ICSE STD. X Preparatory Examination 2024
Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024

xx. Assertion (A): When you pass an object as an argument to a function , it


is called as pass by reference.
Reason(R) : The reference of an object is passed as parameter and not the
value of the argument.
a. Both Assertion (A) and Reason (R) are true and Reason (R) is a
correct explanation of Assertion (A)
b. Both Assertion (A) and Reason (R) are true and Reason (R) is not a
correct explanation of Assertion(A)
c. Assertion (A) is true and Reason (R) is false
d. Assertion (A) is false and Reason (R) is true

Question 2
3
i. Write the java expression for √(𝑎 + 𝑏)2 [2]
Ans: Math.cbrt(Math.pow(a+b),2)

ii. Evaluate the expression when the value of p=5 [2]


p*=++p + --p/++p +p;
Ans: 60

iii. The following code segment should add the fifth and eight elements of the
array and display the answer as 56. However the code has errors. Fix the
code so that it compiles and runs correctly. [2]
int s[]={2,22,3,32,4,42,5,52};
if(s[3]%2==0)
int sum=s[5]+s[7];
System.out.println(sum);

Ans: sum should be initialized before the if condition and the value s[5]
should be changed to s[4]

iv. John executes the following line of the program and the answer displayed
will be a floating-point value, but he expects to get the answer as 0. Name
the error and how can the given statement be modified.
System.out.println(Math.sqrt(2)/10); [2]

Should explicitly convert the print statement to int


System.out.println((int)Math.sqrt(2)/10); The error is logical error

v. How many times will the loop be executed? What will be the output? [2]

int a=12010;int d;
while(a>0)
{
KARNATAKA ICSE SCHOOLS ASSOCIATION
ICSE STD. X Preparatory Examination 2024
Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024

d=a%100;
if(++d/3==0)
break;
else
a=a/1000;
System.out.println(d);
}

Ans: 11
13
The loop will be executed twice

vi. What will be the output of the following string methods? [2]
a. System.out.println("All the Best".length()/2);
Ans: 6
b. System.out.println("Acquatic".equalsIgnoreCase("ACQUATIC"));
Ans: true

vii. Differentiate between actual and formal parameters. [2]


Ans: Actual parameters : Defined in method call.
Formal parameters: Parameters in method definition and preceded by
data type.

viii. Predict the output of the following: [2]


String s="123.45";
int x=Integer.parseInt(s.substring(0,3));
float y=Float.parseFloat(s.substring(3));
System.out.println(x+y);
Ans: 123.45
ix. Name the following: [2]
a. The return type of compareTo function
Ans: int

b. A principle of OOP, which allows a method to be used for multiple


purposes.
Ans: Polymorphism

x. Give the output of the following code-snippet: [2]


double z[]={0.3,4.5,23.0,4.5};
System.out.println(Math.pow((z[1]+z[3]),2));
System.out.println(z.length);
Ans: 81.0
4

SECTION B
KARNATAKA ICSE SCHOOLS ASSOCIATION
ICSE STD. X Preparatory Examination 2024
Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024

(Answer any four questions from this Section.)


The answers in this section should consist of the programs in either BlueJ environment or any
program environment with java as the base.
Each program should be written using variable description / mnemonic codes so that the logic
of the program is clearly depicted.
Flowcharts and algorithms are not required

Question 3 [15]

Design a class named Bill, which will contain the following members:
Data Members:
units,amt of int data type.
Member Functions:
Parameterised constructor to initialise units.
void show( ) to display the contents of units and amt.
void compute(int u ) :calculate the electricity bill with the help of the below
mentioned charges:
• 1 to 100 units – Rs.10/unit
• 100 to 200 units – Rs.15/unit
• 200 to 300 units – Rs.20/unit
• above 300 units – Rs.25/unit

In the main( ) create an object and initialise u with any value and calculate
amt by invoking the compute( ) function and display the contents of U an
amt using show( ) function.

Class name – 1 mark


Data members – 1 mark
Method names – 1 mark
If conditions together – 4 marks( 1 mark each )
Calculation of bill- 4 marks(I mark each)
Main method- I mark
Creating an object -1 mark
Calling of functions- 2 marks( I mark each)

Question 4 [15]

Write a program to input height of 10 Students in feet ( like 5.8, 6.1, …..) in
a single dimensional array. Sort the heights in ascending order, using
bubble sort technique and display the sorted array.

Variable description – 2 marks


Initialising the array – 1 mark
Accepting elements in an array – 2marks
Bubble sort technique
KARNATAKA ICSE SCHOOLS ASSOCIATION
ICSE STD. X Preparatory Examination 2024
Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024

For loop -4 marks(2 marks each for loop)


Initializing the vaiables – 1 mark
Swapping the variables – 3 marks
Displaying the sorted array – 2 marks(I mark for the for loop and 1 mark for
the print statement)

Question 5 [15]

Write a program to accept a string and convert it into uppercase. Replace all
the vowels in the string with the character ‘#’ and display the new string.

Variable Description – 2 marks


Accepting a string -1 mark
Initializing a new string – 1 mark
Upper case conversion 1 mark
For loop -2 marks
Character extraction 2 marks
If condition -3 marks
Creating a new string 1 mark
Displaying the new string -2 marks

Question 6 [15]

Write a program to overload the function display() for the following tasks:

i) To display the following pattern using the function void pattern (char ch,int
n) where n is the number of lines and ch is the character to be printed.
*****
****
***
**
*
ii) To display the sum of the following series
S=𝑎2 + 𝑎4 + 𝑎6 + ⋯ … . . +𝑛 𝑡𝑒𝑟𝑚𝑠
Declaring the methods 2 marks(Should include the parameters properly, if not
no marks allotted)
First method
For loops – 4 marks(2 marks each)
Print statements- 2 marks (1 mark for each statement)
Second method
Accepting a and n from the user – 1 mark
Initializing sum = 1 mark
KARNATAKA ICSE SCHOOLS ASSOCIATION
ICSE STD. X Preparatory Examination 2024
Subject: Computer Applications

Maximum Marks: 100 Time Allowed: 2 hours Date: 24.01.2024

Finding the sum which includes the Math pow function -3


Displaying the sum – 1 mark

Question 7 [15]
Write a program to accept a number and check if it’s a Peterson number or
not.
A number is said to be Peterson if the sum of factorials of each digit is
equal to the sum of the number itself.
For example:
Input: Enter a number=145
Output=1!+4!+5!=145

Variable description 2 marks


Accepting a number – 1 mark
Loop for extraction of numbers – 2 marks
Number extraction logic – 2 marks
Loop for finding the factorial – 2 marks
Initializing the factorial variable – 1 mark
Finding the factorial logic – 2 marks
If condition – 2 marks
Final print statement – 1 mark

Question 8 [15]
Define a class to accept values into a 3×3 array and find the sum of all the
odd numbers in the array.
Example:
Input: A[][]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}};

Output: Sum of odd numbers=5+5+3+5=18

Variable description – 2 marks


Initialising the array – 2mark
Accepting elements in an array – 2marks
Initializing the sum – 1 mark
For loop for the calculation – 2 mark
If condition – 2 marks
Sum calculation – 2 marks
Printing the sum – 2 marks

You might also like