You are on page 1of 6

GARDEN HIGH SCHOOL

CLASS X

Prelims, 2022–23

Computer Applications

Time: 2 hours Full Marks: 100

This Question Paper has six printed pages.


Candidates are allowed additional 15 minutes for only reading the paper.
They must NOT start writing during this time.

This Paper is divided into two sections.


Answer all questions in Section A and any four questions in Section B
The intended marks for questions or parts of questions are given in brackets [ ].

SECTION A (40 marks)


Answer all the questions.

Question No 1
Choose the correct options: [20 × 1 = 20]

(a) In Java, reusability of code is implemented by


(i) abstraction. (iii) polymorphism.
(ii) inheritance. (iv) operator overloading.

(b) Given the code:


int change(int p, int q)
{
p = p*q;
return p;
}
The statement to call the above function will be:
(i) r = change (10, 20.5) (iii) change (9.5, 10.5)
(ii) change (10, 20) (iv) change (10, 20, 1)

(c) How many parameters does a default constructor require?


(i) 3 (ii) 2 (iii) 0 (iv) 1

(d) A programmer wants the members of his class Employee to be accessible only by the
methods of the same class. Which access specifier should he use for the members?
(i) public (ii) private (iii) protected (iv) default
(2)

(e) Which of the following methods belongs to the String class?


(i) setLength() (iii) capacity()
(ii) delete() (iv) setCharAt()

(f) Which is the technique used for binding both data and methods together to keep them
safe from unauthorized access and misuse?
(i) Abstraction (iii) Data Hiding
(ii) Encapsulation (iv) Polymorphism

(g) A Java constructor is a method without


(i) an argument list. (iii) statements.
(ii) a return type. (iv) access specifiers.

(h) Linear search is also known as


(i) binary search. (iii) sequential search.
(ii) interval search. (iv) half-interval search.

(i) Which of the following is not a wrapper class?


(i) Float (ii) Long (iii) Byte (iv) Int

(j) Choose the odd one out:


(i) missing semicolon
(ii) mismatched braces in classes and methods
(iii) misspelt keywords and identifiers
(iv) addition is required but multiplication is performed

(k) Which of the following operators have the highest precedence?


(i) ++ (ii) * (iii) ( ) (iv) >

(l) What will the following code print?


int arr[ ] = new int[5];
System.out.println(arr);
(i) 0 (iii) value of zero index
(ii) null (iv) garbage value

(m) Conversion of primitive data type into corresponding object of wrapper class is known
as:
(i) unboxing. (iii) implicit conversion.
(ii) autoboxing. (iv) explicit conversion.

(n) What is the total size in bytes of the array q[3] of char data type?
(i) 3 (ii) 6 (iii) 12 (iv) 16
(3)

(o) What is the value of x when the following code is executed?


int a[ ] = {1, 3, 4, 5, 6 };
int x = a[2] * a[4] + a[0];
(i) 28 (ii) 24 (iii) 30 (iv) 25

(p) Function prototype means


(i) the name of a function.
(ii) the return type of a function.
(iii) return type, name and arguments to a function.
(iv) parameters of a function.

(q) Study the given code.


int count = 1;
while(count <= 15)
{
System.out.println(count%2 == 1? “***” : “+++++”);
count++;
}
The output of the above code is:
(i) 15 times *** (iii) 15 times +++++
(ii) 8 times *** and 7 times +++++ (iv) both will print only once

(r) Choose the correct syntax for an array with the name arr, data type float and having
length such that its last index is 10.
(i) float arr[10] (iii) arr float[ ] = new arr[10]
(ii) float arr[ ] = new float[11]; (iv) float[ ] arr = new float[10];

(s) System.out.println(Math.floor(–0.42)); will return


(i) –0.0 (ii) 0.0 (iii) 1.0 (iv) –1.0

(t) What is the default data types of floating point numbers in Java?
(i) long (ii) float (iii) double (iv) byte

Question No 2
(a) Write the Java expression for the following: [2]
(a + b)2 + √𝑎 + 𝑏

(b) What will be the output of the following program segment? [2]
int a = 0, b = 10, c = 40;
a – = – – b + c++ + b;
System.out.println(a + “ ” + b + “ ” + c);
(4)

(c) State the need for using wrapper classes in Java programs. [2]

(d) Correct the errors in the following code and rewrite the correct code: [2]
int a = new int(5);
for(int i = 0; i <= 5; i ++)
a[i] = sc.nextInt;

(e) Rewrite the following using a do while loop: [2]


int i, j;
for(i = 5; i > = 1; i – – )
System.out.print(i);

Question No 3
(a) What will be the output of the following function if 5 is passed to it? [2]
void calc(int a)
{
int x = 2;
a = ++a/x + a++/++x;
System.out.println(a);
}

(b) Find the output of the following: [2]


(i) String s = “Today is Test”;
System.out.print(s.lastIndexOf(‘T’));
System.out.println(s.substring(0,8)+ “ ” + “Holiday”);

(ii) int i = 5; [2]


for(i = 5; i >= 1; i– – )
{
if(i%2 == 1)
continue;
System.out.println(i + “ ”);
}

(iii) char c1 = ‘A’; [2]


char c2 = Character.toLowerCase(c1);
int n = (int)c2 – 32;
System.out.println(n + “\t” + c2);

(c) State the method that [2]


(i) converts a string to a primitive float data type.
(ii) determines if the specified character is an uppercase character or not.
(5)

Section B (60 marks)


Answer any four questions.

Answers should consist of programs in either Blue J environment or any program


environment with Java as the base.
Variable Descriptions/Mnemonic Codes should be used to write each program so
that the logic of the program is clearly demonstrated.
Flow charts and algorithms are not required.

Question No 4
Write a program to overload the function series as follows: [15]
(a) void series(): This function prints the following series:
1, 11, 111, 1111, 11111

(b) void series(int a): This function prints the sum of the following series:

a2 a4 a6 a12
+ + + .. . . . . . . +
3! 5! 7! 13!

Question No 5
Write a program to input a number and check whether it is an Abundant number or not.
An Abundant number is a number for which the sum of its proper factors (excluding the
number itself) is greater than the number itself.
For eg. 12 is an Abundant number because its factors are 1, 2, 3, 4, 6 excluding 12. The
sum of the factors is 16 which is greater than 12. [15]

Question No 6
Write a program to input a sentence and convert it to uppercase. Count and display the total
number of words starting with the letter ‘A’.
For eg. ADVANCEMENT AND APPLICATION OF INFORMATION TECHNOLOGY ARE
EVER CHANGING
Output: Total number of words starting with ‘A’ = 4 [15]

Question No 7
Write a menu-driven program to print the following patterns as per the user’s choice: [15]
(a) 1 (b) A
21 BB
321 CCC
4321 DDDD
54321 EEEEE
(6)

Question No 8
Write a program to input 10 cities and their corresponding STD codes in two different
one-dimensional arrays. The program should display the names of only those cities which
begin with a vowel along with their corresponding STD codes. [15]

Question No 9
Design a class named CaseConvert with the following specifications: [15]
Data members: String str1, str2 – to store a string and create a new string
Member methods:
(a) A parameterized constructor to initialize the data members.
(b) void convert(): to obtain a new string after converting each uppercase letter of the
original string to lower case and vice versa
(c) void display(): to display the original string and the new string
Write a main() method to create an object of the class and call the above methods.

You might also like