09-CTA

Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

St.

Stephen’s School, Sector 45-B, Chandigarh


Sample Paper 2023-2024, Computer Applications

Class 9

Time – 2 hrs MM-80

This paper is divided into two Sections. Attempt all questions from Section A and any four
questions from Section B.

Section A (20 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 answers only.)
1. Which is odd in given options

(a) Polymorphism (b) One thing in many forms

(c) Abstraction (d) Function overloading

2. Assertion: Abstraction is the process of hiding the implementation details of an object and expressing
only the relevant features.
Reasoning: Abstraction allows you to focus on what an object does rather than how it does it. helps in
managing complexity.
(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)
(e) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
3. Which loop ends with a semicolon (;)?

a. for b. while

c. do while d. All of these

4. Which statement is used to exit from a loop?

a. return b. break

c. continue d. None of these

5. Name the following: [2]


1. The method which converts a string into an int.
2. A statement that sends the control out of the method.
6. Give examples of the following in Java. [2]

a. Syntax error b. Runtime error

9. Give the output of the following: [2]

a) Math.abs(Math.floor (-5.8)) b) Math.ceil(3.8) + Math.pow(3, 2)

c) Math.floor(-147.349) d) Math.max(64.5,65.4)
Question 2:

1. Write the java expression for the following: [2]


√𝑎² + 𝑏³
2. What are the values of x and y when the following statements are executed? [2]

int a = 56, b = 34;

boolean x = (a < b ) ? true : false;

int y= (a > b ) ? a : b;

3. i)Name the default delimiter that is used in Scanner class. [2]

ii)Name the keyword that allows us to use classes from other packages.

4. What will be the output of the following code? [2]

int k = 5, j = 7;

k += k++ – ++j + k;

System.out.println(“k=” +k);

System.out.println(“j=” +j);

5. Write the output of the following: [2]

System.out.println("Java\"World\"");

System.out.println("Java\nWorld");
Section B (60 MARKS)

Question 3: [15]
Write a program to input a number and check if it is a Strontio number or not. Strontio numbers are those four
digits numbers which when multiplied by 2 give the same digit at the hundreds and tens place. The user should
be forced to input a four-digit number.
Example: Input muber: 1386
1386*2=2772, we observe that at tens and hundreds place digits are the same. Hence, 1386 is a strontio number.
Question 4: [15]
Write a program to create a function isPronic() that inputs a number from the user checks whether the
number entered is a Pronic number or not and displays an appropriate message. A pronic number is a
number which is the product of two consecutive integers, that is, a number of the form n(n + 1).
Example- 6 is a pronic Number as 2x3=6
To calculate the product, it should call a function giveProduct() that returns the product of two
values passed to it.
Note: USE THE SAME FUNCTION NAMES AS GIVEN IN THE QUESTION.
Question5: [15]

Write a menu driven program to calculate and print the sum of each of the following series:

(a) Sum (S) = 1+(1+2)+(1+2+3)+.........+(1+2+3+4+....+20)

(b) Sum (S) =x/1+ x/3+ x/5 + x/7 +…+ x/19

Question 6: [15]
Define a class Mobike with the following description:
Instance variables/data members:

int bno: to store the bike’s number.


int phno: to store the phone number of the customer.
String name: to store the name of the customer.
int days: to store the number of days the bike is taken on rent.
int charge: to calculate and store the rental charge.

Member functions/methods:

void input(): to input and store the detail of the customer.


void compute(): to compute the rental charge.
The rent for a Mobike is charged on the following basis:
First five days: Rs. 500 per day.
Next five days: Rs. 400 per day.
Rest of the days: Rs. 200 per day.
void display(): to display the details in the following format:
Bike No Phone No Name No. of days Charge
———– ————– ——— —————– ———–
Question 7: [15]
Write a program in Java to read a number, remove all zeros from it, and display the new number.
For example:
Input: 4507703
Output: 454773
Question 8: [15]

Create a function which accepts an integer as a parameter and prints the factorials of all numbers till the
parameter passed.
Input:
Parameter passed: 5
Output:
Factorial of 1=1
Factorial of 2=2
Factorial of 3=6
Factorial of 4=24
Factorial of 5=120
***********

You might also like