SECOND Term Examination - 2024
Computer Applications
Grade: 10 Duration: 2 Hours
Date: 20-11-2024 Max. Marks: 100
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
reading the question paper. The time given at the head of this paper is the time allowed
to write 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.)
For loop-based output questions, show the dry run in a tabular form, and for other
output questions show the working.
Question 1
Choose the correct answers to the questions from the given options. (Do not copy the
question, write the correct answers only.)
1. When a class serves as a base class for many derived classes, the feature is called
a. Polymorphism b. Encapsulation c. Inheritance d. Abstraction
2. The expression that uses the && operator is called a ___________________.
a. Relational Expression b. Logical Expression
c. Arithmetic Expression d. Assignment Expression
3. The precedence of shorthand operator is_____________ than of Unary operator.
a. Higher b. Lower c. Equal d. Not related
4. When the object of a wrapper class is assigned to a primitive type variable, the object is
automatically converted to the primitive type. This is called as
a. Unboxing b. Boxing c. Implicit Conversion d. Inheritance
5. 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
6. The wrapper class of char type is
a. character b. Character c. char d. Char
7. The output of [Link]([Link]([Link](-4.3,-7.8))); is
a. -7.0 b. -8.0 c. 7 d.6
8. Which of the following is not a token?
a. Byte code b. identifiers c. literals d. operators
9. Name the type of error in the following statement
[Link](10/(35%5));
a. Syntax error b. Logical error c. Runtime error d. No error
10. The size of the array int a[ ]={ 3,8,2,1,12,11,13}; is
a. 6 b. 7 c. 9 d. 8
11. What will be the value of H in the given statements?
String a = "Success", b = "Happiness";
boolean H = [Link](4).equals([Link](6));
a. ess b. ness c. true d false
Page 1 of 5
12. Name the package that contains wrapper classes:
a. [Link] b. [Link] c. [Link] d. [Link]
13. The Java statement to access the 5th character in the string str is:
a. [Link](i) b. [Link](4) [Link](5) d. [Link]()
14. A method prototype that has function name display() which takes two characters as an
input and an integer number as a return type is
a. void display(char a, char b) b. int display(int a ,int b)
c. int display(char a ,char b) d. char display(int a ,int b)
15. The method compareTo() returns _______when two strings are equal.
a. true b. 0 c. 1 d. false
16. Which of the following is a valid String constant?
a. true b. ‘false’ c. false d. “true”
17. The output of the following snippet is
[Link]("Output is ");
for(int m=5;m<=50;m+=5)
{ if(m%6==0)
continue;
else if(m%3==0)
[Link](m); }
a. Output is 15 b. 16 35 c. Output is 45 d. 45 15
45 15
18. Assertion (A): A loop in which there is no statement associated with its body is called
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
19. Read the following text and choose the correct answer
A constructor is a special member function used to initialize the data members whenever an
object is created for the class. The different types of constructors are Default constructor
Parameterized 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 initialized to a data type.
d. A pure function needs to be created to call the constructor
20. Assertion (A): When you pass an object as an argument to a function, it is called pass
by reference.
Reason(R) : The reference of an object is passed as a 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
Page 2 of 5
Question 2
1. Write the java expression for |3√(𝑎 + 𝑏)2| [2]
2. Evaluate the expression when the value of p=5 [2]
p*=++p + --p/++p +p;
3. 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];
[Link](sum);
4. John runs the following line of code, expecting the result to be 0, but instead, a floating-
point value is displayed. Identify the error and suggest how the statement can be
corrected.
[Link]([Link](2)/10); [2]
5. How many times will the loop be executed? What will be the output? [2]
int a=12010;int d;
while(a>0)
{
d=a%100;
if(++d/3==0) break;
else a=a/1000;
[Link](d); }
6. What will be the output of the following string methods? [2]
[Link]("All the Best".length()/2);
[Link]("Acquatic".equalsIgnoreCase("AQCUATIC"));
7. Differentiate between actual and formal parameters. [2]
8. Predict the output of the following: [2]
String s="123.45";
int x=[Link]([Link](0,3));
float y=[Link]([Link](3));
[Link](x+y);
9. Name the following: [2]
a. The return type of startsWith function.
b. A principle of OOP, which allows a method to be used for multiple purposes.
10. Give the output of the following code-snippet: [2]
double z[]={0.3,4.5,23.0,4.5};
[Link]([Link]((z[1]+z[3]),2));
[Link]([Link]);
Page 3 of 5
SECTION B
Answer any four questions from this Section.
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 that contains the following members:
Data Members:
units, amt of int data type.
Member Functions:
Bill(int U) : Parameterized constructor to initialize units.
void show( ) : to display the units consumed and the bill amt.
void compute() : calculate the electricity bill amount based on the slab rates given
below.
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 using the parametrized constructor, calculate the amt by
invoking the compute( ) function and invoke the show method () to display the Units consumed
and the bill amount.
Question 4 [15]
Write a program to input the height of 10 Students in feet and inches (like 5.8) and so on in a
single-dimensional array. Sort the heights in ascending order, using the bubble sort technique,
and display the sorted array.
Sample input:
Enter heights of 10 students (in [Link] format): 5.8 5.6 6.1 5.9 5.5 6.0 5.7 5.4 5.3 6.2
Sample output:
Heights sorted in ascending order: 5.3 5.4 5.5 5.6 5.7 5.8 5.9 6.0 6.1 6.2
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.
Sample input: Enter a string: Hello World
Sample output: Modified String: H#LL# W#RLD
Page 4 of 5
Question 6 [15]
Write a program to overload the function display() for the following tasks:
void display (char ch, int n) : displays the given character ch as per the given sample
n is the number of lines and ch is the character to be printed.
Sample input:
if ch = * and n = 5
Sample output:
The following pattern will be printed.
*****
****
***
**
*
int display(int a, int n) : returns the sum of the following series
𝑎2 + 𝑎4 + 𝑎6 + ⋯ … . . +𝑛 𝑡𝑒𝑟𝑚𝑠
Sample input: a = 2 n = 4
Sample output:
Sum of series: 22+24+26+28 is 340
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.
Sample input: Enter a number=145
Sample output: 145 is a Peterson number.
Sample input: Enter a number=123
Sample output: 123 is not a Peterson number.
Question 8 [15]
Define a class to accept values into a 3×3 array, find the sum of all the odd numbers in the
array and display the same.
Sample input: A[ ][ ]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}};
Sample output: Sum of odd numbers=5+5+3+5=18
Page 5 of 5