0% found this document useful (0 votes)
56 views5 pages

Computer Applications Pre-Board Exam 2023

Uploaded by

Vivek Varma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
56 views5 pages

Computer Applications Pre-Board Exam 2023

Uploaded by

Vivek Varma
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

SOUTH END SCHOOL

Affiliated to CISCE, New Delhi (ICSE)


Affiliation No. WB420
Nalhati, Birbhum
X
PRE-BOARD EXAMINATION YEAR 2022-23

Maximum Marks - 100 Subject – Computer Applications (Theory) Time - 2 Hours


_______________________________________________________________________________________

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 (40 Marks)


(Attempt all questions from this Section.)
Question 1 [20]
Choose the correct answer and write the correct option:

(i) The principle of OOP languages that highlights the essential features and hides the
background details is known as:
(a) Polymorphism (b) Encapsulation (c) Data abstraction (d) Inheritance
(ii) String is a:
(a) Class (b) Data type (c) Group of characters (d) All of these
(iii) [Link] (23.6) + [Link] (28.5) = _______
(a) 52.0 (b) 53 (c) 52 (d) 53.0
(iv) The memory required to store the constant value 78L is:
(a) 2 bytes (b) 4 bytes (c) 8 bytes (d) 16 bytes
(v) The Scanner class is included in ________ package.
(a) [Link] (b) [Link] (c) [Link] (d) [Link]
(vi) A _______ method needs to be called with the help of an object.
(a) static (b) non-static (c) public (d) None of these
(vii) Which Character function is used to check if a letter is in upper case or not ?
(a) isUpperCase() (b) toUpperCase() (c) UpperCase() (d) touppercase()
(viii) Predict the output:
[Link] ((int) [Link]("5.67")+0.33);
(a) 6.0 (b) 5.33 (c) 5.0 (d) 6.33
(ix) Division by 0 is an example of:
(a) Run-time error (b) Compile-time error (c) Logical error (d) All of these

Page 1 of 5
(x) The number of bytes occupied by an array of type char and size 5 is:
(a) 5 (b) 10 (c) 20 (d) 80
(xi) The return data type of a class method can be:
(a) int (b) void (c) String (d) All of these
(xii) Predict the value of r wherein r = 45 + "ZEBRA".charAt(2);
(a) 135 (b) 114 (c) 111 (d) 45A
(xiii) Given an array int p[ ] = {4, 6, 7, 2, 6, 5, 8}; The value of p[3] + p[5] is:
(a) 7 (b) 8 (c) 13 (d) 15
(xiv) Which of the following is not a token ?
(a) Literal (b) Identifier (c) Operator (d) Statement
(xv) Predict the output of the following expression:
"EFFECT".compareTo("AFFECT");
(a) 0 (b) 4 (c) -5 (d) false
(xvi) Default value of reference data type is:
(a) null (b) 0 (c) false (d) ""
(xvii) A loop can have ________ enclosed inside it.
(a) 1 loop (b) 2 loops (c) 3 loops (d) any number of loops
(xviii) The statement, [Link]("Seven"+7+7); gives the output:
(a) Seven14 (b) Seven77 (c) 7Seven7 (d) 21
(xix) Which of the following is not an access specifier ?
(a) protected (b) public (c) private (d) return
(xx) for(int a=10;a>=1;a-=2)
{
for(int b=1;b<=5;b++)
{
[Link](a+b);
}
}
How many times the inner loop will get executed ?
(a) 5 (b) 10 (c) 25 (d) 50

Question 2
(i) Define Unboxing with an example. [2]
(ii) State two differences between Call by value and Call by reference. [2]
(iii) Evaluate: e- = --x + y++ * x-- + y; when e = 10, x = 1 and y = 0 (Show working). [2]
(iv) Write an equivalent Java expression for the following mathematical expression: [2]
| √𝑢2 + 2𝑎𝑠 |
(v) What is NullPointerException ? Give an example. [2]

Page 2 of 5
(vi) Rewrite the following code segment using ternary operator: [2]
if(p>1000)
d = p * 5/100.0;
else
d = p * 2/100.0;

(vii) Go through the following program and answer the questions given below: [2]
public class PreBoard2023
{
int x, y, z;
PreBoard2023 (int a, int b, int c)
{
x = a;
y = b;
z = c;
}
private void addMarks()
{
int total = x + y + z;
[Link]("Total Marks = "+total);
}
}
(a) Name the member variables.
(b) Name the type of the constructor used.
(c) Name the variable declared within the method body.
(d) State the total number of method variables used.

(viii) Predict the data type and value of the variable res in the following statement: [2]
_______ res = "Knowledge".substring(0,4).concat("Mind");
(ix) Write a Java statement to replace 'E' with character 'A' in the word "INCIDENCE". [2]
(x) Go through the code given below and answer the following questions (Show working). [2]
int h = 0, i = 0;
while(h<=5)
{
h++;
if(h%2==0)
continue;
[Link](i);
i++;
}
(i) What will be the total number of executions of the loop ?
(ii) What will be the output ?
Page 3 of 5
Section B (60 Marks)
(Attempt 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 base.
Each program should be written using Variable descriptions / Mnemonic Codes so that the logic of the
program is clearly depicted.
Flow-charts and algorithms are not required.

Question 3
Design a class ‘Epidelco’ with the following specifications: [15]

Class name: Epidelco


Member variables:
double sale : to store the amount of sale
double com : to calculate and store the commission

Member methods:
Epidelco (double s, double c) : parameterized constructor to initialise the member
variables
void inputData() : to accept the amount of sale
void computeData() : to calculate the commission as per the following table -

Sale Amount Commission on sale


Up to ₹1,000 5%
₹1,001 to ₹2,000 10%
₹2,001 to ₹5,000 15%
Above ₹5,000 25%

void printData() : to display the amount of sale and commission in separate


lines

Define a main() method to create an object of the above class and invoke the member
methods to get the desired result.

Page 4 of 5
Question 4
Define a class to overload a method display() for the purposes as follows: [15]

void display (int n) : to calculate and display the factorial of n


void display (int n, double x) : to display the sum of the following series:
𝑥 𝑥 𝑥
𝑥 + + + + ….. up to n terms
2 3 4
void display () : to display the following pattern:
4
45
456
4567

Question 5
Define a class to accept 10 integers (including positive and negative integers) in a single
dimensional array (SDA). Display all the negative numbers followed by the positive numbers
without changing the order of the numbers. [15]
Sample Input: 8, -7, 4, -3, 7, 23, -4, 98, -90, 33
Sample Output: -7, -3, -4, -90, 8, 4, 7, 23, 98, 33

Question 6
Write a program to declare an array for accepting a list of 30 integers. Sort the first 15
numbers in ascending order and the last 15 numbers in descending order by using the
mechanism of ‘Bubble Sort’. Finally print the original as well as the resultant array. [15]

Question 7
A ‘Palindrome word’ is a word that is identical to its reverse word and a ‘Special word’ is a
word that starts and ends with the same letter.
Define a class ‘PalinSpecial’ to accept a word and check whether the word is “Only
Palindrome”, or “Only Special”, or “Palindrome as well as Special” or “Neither Palindrome nor
Special”. [15]

Question 8
Write a program to declare an array country[ ] to accept and store the name of 10 countries
in alphabetical order and another array capital[ ] to accept and store their respective capital
cities. Now ask the user to enter the name of a country and search it using the technique of
‘Binary search’ in the first array. If it is found, display the name of the country along with its
capital city, otherwise display the message “COUNTRY NOT FOUND”. [15]

Page 5 of 5

Common questions

Powered by AI

The given code consists of two nested loops: the outer loop decreases variable 'a' from 10 to 1 in steps of 2, while the inner loop executes 5 times for each iteration of the outer loop. The expression 'a+b' prints a series of numbers starting with a+b where 'a' is current from the outer loop and 'b' ranges from 1 to 5. Each outer loop iteration results in five numbers printed, thus the inner loop executes 25 times in total, given there are 5 cycles of the outer loop (10, 8, 6, 4, 2).

Binary search is preferred over linear search for finding elements because it significantly reduces the search time complexity from O(n) to O(log n). This efficiency is crucial when dealing with large datasets, such as an array of countries and capitals. Binary search works on the principle of divide and conquer, requiring a sorted array, which cuts down the number of comparisons drastically by halving the search space at every step, whereas linear search requires checking each element until the target is found or the end is reached .

NullPointerException in Java occurs when a program attempts to use a null object as though it were a properly initialized object. For instance, if a programmer tries to access a method or field of an object that hasn't been instantiated with new, such as calling a method on a null array, the program will throw a NullPointerException. An example scenario is attempting to call a method on an object reference that is set to null, e.g., "String str = null; int length = str.length();" would trigger this exception .

Evaluating the given expression results in converting the character at index 2 of the string "ZEBRA" to its Unicode value. The character is 'B', which has a Unicode value of 66. Therefore, the expression evaluates to 45 + 66, resulting in a total of 111 .

To implement a class that calculates commission based on sales amount, follow these steps: 1) Define a class 'Epidelco' with member variables to store sales and commission. 2) Implement a parameterized constructor to initialize these variables. 3) Create a method 'inputData()' to accept the sales amount. 4) Implement 'computeData()' where commission is calculated based on predefined brackets: up to ₹1,000 at 5%, ₹1,001 to ₹2,000 at 10%, ₹2,001 to ₹5,000 at 15%, and above ₹5,000 at 25%. 5) Include 'printData()' to display sales and commission values. Finally, create a 'main()' method to instantiate the class and invoke member methods .

Encapsulation involves bundling the data (attributes) and methods (functions) that work on the data into a single unit or class, and restricting access to certain components. This principle can be compared to the way private individuals protect their personal information: only certain trusted people, like family or doctors, have access, similar to how access modifiers like private, protected, and public control access in programming. By managing who has access to what data, encapsulation ensures the integrity and security of an object's internal state, just like keeping personal details secure in real life .

The given code can be rewritten using a ternary operator as follows: "d = (p > 1000) ? p * 5/100.0 : p * 2/100.0;" This single-line approach simplifies the if-else statement by replacing it with the ternary (conditional) operator, which checks the condition and selects one of the two values based on whether the condition is true or false .

Call by value involves passing a copy of the actual parameter's value to the function, meaning changes made to the parameter inside the function do not affect the original variable. On the other hand, call by reference passes the actual memory address of the parameter, allowing the function to modify the original variable's value. This distinction is crucial because it influences how data is manipulated within functions and affects memory efficiency and function behavior .

Data abstraction in object-oriented programming languages helps manage complexity by allowing developers to focus on high-level design without worrying about the implementation details. It emphasizes essential features while hiding unnecessary details, making it easier to manage large code bases and improve code readability and maintainability. This concept enables developers to construct a system architecture that is both flexible and scalable because the underlying implementation can change without affecting how objects interact within the system .

The 'substring' method is vital in Java for extracting specific parts of a string, allowing for precise control over string manipulation. It operates by returning a new string that is a substring of the specified string, starting at the specified beginIndex and extending to the character at endIndex minus one. When used in conjunction with concatenation, it allows for the assembly of strings in a manner that combines extracted parts with other strings or characters seamlessly, enabling complex string generation and modification .

You might also like