0% found this document useful (0 votes)
17 views4 pages

Computer Application Exam Class X

This document is an examination paper for Computer Applications for Class X at Bishop Cotton Girls' School, covering various programming concepts and Java-related questions. It includes multiple-choice questions, coding exercises, and programming tasks related to data types, methods, classes, and control structures. The exam is structured into two sections, with Section A requiring all questions to be attempted and Section B allowing students to choose four questions.

Uploaded by

emily16852.9a
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)
17 views4 pages

Computer Application Exam Class X

This document is an examination paper for Computer Applications for Class X at Bishop Cotton Girls' School, covering various programming concepts and Java-related questions. It includes multiple-choice questions, coding exercises, and programming tasks related to data types, methods, classes, and control structures. The exam is structured into two sections, with Section A requiring all questions to be attempted and Section B allowing students to choose four questions.

Uploaded by

emily16852.9a
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

J e s a Susan JoRn

M- SCHOOL
E

BISHOP COTTON GIRLS'

EXAMINATION NOV-DEC 2022


SECOND TERM
COMPUTER APPLICATION

TIME: 2 hours
CLASS:X
Marks: 100
Date: 01/12/2022
15 minutes. This time is to be spent in reading the
You will not be allowed to write during the first
is the time allowed for writing the
answers.

question paper. The time given at the head of this Paper


parts of questions are given
in brackets [].
The intended marks for questions or

SECTION A (Attempt all questions)

Question1
Choose the correct answer and write the correct option. [201
called as
(1) When primitive data type is converted to its corresponding object of its class, it is

(a) Boxing (b) Explicit type conversion


(c) Unboxing (d) Implicit type conversion

State the value of y after the following is executed:


(ii)
char x="7;
[Link](x);
(a) false (6) 7 (C) true (d) 7

(ii) Give the output of the following string methods:


"MISSISSIPPI".indexOf('S')+ "MISSISSIPPI".lastIndexOf(T)
(a) 10 (b) 12 (c) 20 (d) 11

data type is
(iv) Corresponding wrapper class ofint
(a) integer 6) INTEGER (c) Int (d) Integer

with in the body of a method is termed as:


(v) Variable that is declared (c) Local variable (d) Argument variable
(a) Instance variable 6) class variable

declaration statement:
(vi) Identify the correct array (c) intarr[ij=10; (d) int a[10]-new int[]:
(a) int af10) (6) int a[]Fnew int[10];

itself is called as:


(vii) A variable that is bounded to the object (c) Local variable (d) Argument variable
variable
(a) Instance variable (b) class
is:
(viii) The access modifier that gives most accessibility
(a) private (b) public (c) protected (d) package

code:
(ix) Give the output of the following
String A "26.0", B="74.0";
double C= Double .parseDouble(A);
double D= Double .parseDouble(B);
[Link]((C+D);
(c) 100.0 (d) 2674
(a) 2674.0 (b) 100
x) Wrapper classes are available in
(a) [Link] (6) [Link] package.
(c) [Link] (d) [Link]
(xi) Which of the following are valid comments?
(i)/* comment */
(ii) /* comment
(iii) // comment
(iv) */ comment */
a) (i) & (iii) b) )& (i) c) (1) &(iv) d) (ii) & (ii)
(xii) Operators with higher precedence are evaluated before operators with relatively lower
precedence. Arrange the operators given below in order of higher precedence to lower
i) && (ii) % i i ) >= (iv) ++
precedence
a) (iv), (i), (ii), (i)
b) (iv), (i), (i), (i)
c)(iv), i). (Gii). (i)
d) i), (ii). (ii). iv)
(xii) Which of the following keyword is used to create an instance of a class?
a) new b) public c) class d) None of the above

(xiv) What is the final value stored in variable x ?


double a =-8.35;
double x =

[Link]([Link](a));
a) 9.0 b) 7.0 c) 6.0 d) 8.0

(xv) Name the type of error in the statement given below:


int r=100/0;
a) Syntax b) Runtime c) Logical d) None of the above

(xvi) The
a) Inheritance
allows a class to use the properties and methods ofanother class.
b) Polymorphism c)Encapsulation d) None of the above

(xvii) The number of bytes occupied by char data type is byte/s


(a) 4 (b) 8 (c) 2 (d)1
(xvii) The are the words which have special meaning
(a) Keywords (b) Identifier (c) Methods (d) Package
(xix) Method that accepts a string without any space is
(a) next) (6) nextlLine0 (c) nextlnt) (d) [Link](0)

(xx) The is called instance of the class.


a) Object b) Attributes c) State d) None

Question2
a) State the datatype and value of y after the following is executed:
21
char x ="7;
y= [Link](x);
b) What is the value of x1 ifr=5? (2
xl=++x - x t + + --x
(2
c) Write the output for the following:
String s="Today is Test";
[Link]([Link](T);
[Link]([Link](0,7) + * *+ "Holiday");

What values stored in variable rl and


r2: 121
d) are

(i) doublerl =[Link]([Link](-2.83,-5.83);


double r2 [Link]([Link](16.3)):
(i) (2
code:
e) Give the output of the following
String A="26", B="100*";
String DA+B+"200";
int x= [Link](A);
[Link](B);
int d= x+y
[Link]("Result 1 = + D ) ;

[Link]("Result 2="+d);
1) Analyse the given program segment and
answer the following: [2
for(inti-3; i<=4; it+)
for(int j-2; jsi; j++)
[Link](");
[Link](*WIN"); }|
(i) How many times does the inner loop execute?
(i) Write the output of the program segment.
g)What are the types casting shown by the following
of examples: [21
) char c = (char)120;

(ii) int x = t';

| 2ab-a| [21
h) Write the Java expression for: ab
Convert the following do-while loop into for loop. 2]
i)
inti 1, d=5;
do
d-d*2;
[Link](d);
itt
while(i<=5);

j) Rewrite the statements below correctly to assign values to an integer array. 21


int a = new int(5);

for(inti-0; i-5; it+) a[i] =i;

SECTION B(Attempt any four questions)


Each program should be written using Variable descriptions/Mnemonic Codes such that the logic of
the program is clearly depicted.

Question 3 [15
Define a class BookFair with the following description:
Instance variables/data members:
the name of the book
String Bname: stores
stores the price of the book
double price
Member methods: members
initialize the data
BookFair() constructor to of the book
and price
to input and store
name

void input()
the table below
after discount as per
void
calculate() :tocalculatetheprice Discount
Price
2% of price
to z1000
Less than or equal
equal to 73000 10% of price
More than 1000
and less than or

15% of price
More than R3000
discount.
book after
and price of the member methods.
: todisplay the name the above
voiddisplay()method to create an object
of the class and call
Write a main
[15
Question 4
overload a function Print() as follows:
Design a class to of the series given beloW
void Print(int x, int n)
(a) - To display the sum . . . X" terms
x+x* +x +. below:
in lower case as given
(b) void Print() To display the series of alphabets
a, c, e, g..
*****°'*****.

a number is
To check whether the number
is Dudeney number,
(c) boolean Print(inta)
dudeney if the cube of the sum
of the digits is equal to the
512= (5+1+2)=(8)°=512
numberitself. Forexample:
[15]
Question5 numbers in a single dimensional array. Sort the
a set of 10 different
Write program to accept
display the sorted list.
a
bubble sort technique and
numbers in ascending order using

Question 6
[15
into array. Display the following:
class to accept and store 20 strings
an
Define a
number of characters,
) all strings in the array with even
ii) the longest string in the array.

Question 7
(151
write a menu driven program to do the following:
Using the switch-case statement,
Generate a series of numbers as: 1,-3, 5,-7, 9, .. .n
1) statement: ABCDE
2) Display a pattern using iteration (looping) ABCD
ABC
AB
A
Question 8 15
and their corresponding phone numbers, store
Write a program to accept 10 different names
them in two single dimensional arrays. Now, enter a name. By using linear search technique
of array elements. If present display the name
check whether or not the name is present in the list
with the phone number otherwise display a suitable message.

Common questions

Powered by AI

Type casting in Java allows variables of one data type to be converted to another, providing flexibility in assignments between compatible types. In 'char c = (char)120;', an explicit cast is used to convert the integer 120 to its equivalent ASCII character, demonstrating narrowing conversion. Conversely, in 'int x = 'a';', an implicit cast occurs where the character 'a' is automatically converted to its ASCII integer value, showcasing widening conversion without the need for explicit casting .

In Java, attempting to divide an integer by zero results in a runtime error. This is because runtime errors occur during the execution of a program, as opposed to syntax errors that are identified during compilation. Therefore, the statement 'int r=100/0;' triggers a runtime error, as division by zero is not allowed .

Access modifiers in Java dictate the visibility of classes, methods, and other members. 'Public' is the most permissive access level, granting visibility to every other class regardless of the package. This means any public class member can be accessed from any other class without restrictions. However, using public access comes with the risk of reducing encapsulation by exposing internal states or behaviors to broader access than necessary, which might compromise modular design principles .

Wrapper classes in Java are examples of object-oriented programming concepts, specifically abstraction and encapsulation. They allow primitive data types (such as int, char, double) to be converted into objects, making them act as objects. This is achieved through 'boxing', where a primitive data type is converted to its corresponding wrapper class object like Integer, Character, or Double . Wrapper classes are part of the java.lang package .

Method overloading in Java allows multiple methods with the same name to coexist in a class, differentiated by their parameter lists. The 'Print()' method exemplifies this by having different implementations for distinct tasks. One version of 'Print(int x, int n)' computes the sum of a series based on input parameters, while another 'Print()' outputs a series of alphabets. Additionally, 'boolean Print(int a)' checks for Dudeney numbers, a specific numerical property. This overloading enables the 'Print()' method to perform tasks of varied complexity under a unified interface .

In a Java menu-driven program, a switch-case statement is used to execute different blocks of code based on user input. It evaluates the expression provided in the switch argument and matches it against various case labels. For example, for generating a number series (1, -3, 5, -7, ...) and displaying patterns, each option presented to the user would correspond to a case. Based on the user's choice, the corresponding block of code executes to produce the desired output, while 'break' statements ensure that subsequent cases do not execute inadvertently .

The 'BookFair' class in a Java program can encapsulate data about books and manage their discounts using methods. It can have instance variables for storing the book's name and price. The input() method could prompt for the book's name and price and store these values in the variables. The calculate() method could apply discount rules based on price, decreasing the price by a percentage (2%, 10%, or 15%) depending on the price range. The display() method would then print the adjusted price and book name, thus ensuring that all operations related to a book's pricing are handled within a single cohesive class structure .

Java evaluates arithmetic operations based on operator precedence, meaning that operators with higher precedence are evaluated before those with lower precedence. For instance, increment (++), and modulo (%) have higher precedence than logical operators like && and comparison operators like >=. In a given expression, operations are performed in order from higher to lower precedence, and if operators have the same precedence, they are evaluated from left to right .

Linear search involves traversing an array from the beginning to the end, comparing each element with the target value to find a match. The key steps include initializing an index, looping through the array, and checking each element against the desired name. If a match is found, the index is returned or relevant information displayed; if no match is found after traversing the entire array, an appropriate message is returned. The main limitation of linear search is its inefficiency on large data sets as its time complexity is O(n), making it slower compared to more sophisticated search algorithms like binary search .

Bubble sort is a simple sorting algorithm that sorts an array by repeatedly stepping through the list to be sorted, comparing each pair of adjacent items, and swapping them if they are in the wrong order. This process is repeated until the list is sorted. The computational complexity of bubble sort is O(n^2), where n is the number of items being sorted, because each pass through the list potentially involves swapping n-1 pairs and n such passes might be required in the worst case .

You might also like