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

Class X Computer Applications Exam

Uploaded by

0613.apobangpo.7
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)
68 views4 pages

Class X Computer Applications Exam

Uploaded by

0613.apobangpo.7
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

THE BISHOP’S SCHOOL, CAMP

FIRST PRELIMINARY EXAMINATION


SUBJECT: COMPUTER APPLICATIONS
CLASS: X MARKS: 100
DATE:24.11.2022 TIME: 2HRS
===========================================================
Answer 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 in reading the question paper.
The time given at the head of this Paper is the time allowed for writing 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 (40 marks)
Attempt all questions
Question 1 [20]
Choose the correct answers to the questions from the given options.
(Do not copy the questions , write the correct answer only.)
1. Which of the following is a super class of all other java classes?
a. Object b. Math c. System d. Import

2. Which of the following is the output of below code snippet?


double x= - 3.142;
int y =(int)[Link](x)+(int)x;
[Link](y);
a. 0 b. 6.284 c. 6.0 d. -6

3. When an object of a class is converted to a simple data type is called_________.


a. Unboxing b. boxing c. explicit type conversion d. Implicit type conversion

4. Which of the following methods of Java return nearest and largest whole number which is
greater than or equal to the argument?
a. ceil b. floor c. trim d. max

5. Which of the below specifiers provide minimum security for the class members?
a. private b. protected c. public d. default/friendly access

6. _______variables are the variables declared inside a method and have a scope limited to the
method. They cannot be accessed outside the method.
a. Static b. local c. global d. protected

7. [Link](“Be happy, not because everything is good but because you can see the
good in everything”.substring(40).length());
a. 47 b. 46 c. 45 d. 40

8. What is the output for:


[Link](“Malayalam”.replace(„a‟,‟z‟).substring(3,6));
a. Mzlzyzlzm b. Mzlayalam c. zyz d. zyzl

9. Which of the following method can be used to convert String objects to integer objects?
a. toString() b. valueOf() c. Both (a) and (b) d. None of the above

1
10. Decide how many searches using linear search it will require to successfully search for 2
from the below array?
15 12 2 3 4 5
a. 2 b. 3 c. 4 d. 5

11. What is printed by the below statements?


int num[]={11,22,33,44,55};
[Link](num[2]+”\t”+num[1]+”\t”+num[3]+”\t”+num[4-2]);
a. 33 55 11 22 b. 33 11 44 33 c. 55 11 22 44 d. None of these

12. Absence of break in switch statement causes:


a. Runtime error b. Syntax error c. no error d. Logical error

13. Given the code:


int num;
for(num=1; <=5;num++);
[Link](mum);
What will get printed?
a. 1 b. 4 c. 5 d. 6

14. What will be the output for: [Link]([Link](„A‟)+1);


a. 66 b. 6 c. error d. 98

15. A class is also known as __________


a. Primitive data type b. Constructor c. Composite data type d. Simple data type

16. System and Math classes are contained in _________packages.


a. lang b. io c. util d. api

17. Which of the following statements are valid for a string declaration?
a. String d= null; b. String d= „null‟; c. String d=0; d. String d= (String) “Hello”;

18. Which of the following types of functions does not return a value?
a. Pure method b. Impure method c. Specific method d. None of these

19. ______fields may be accessed by all subclasses of the current class, but are not visible to
classes outside of the current package.
a. Public b. protected c. private d. default

20. Based on the below code snippet, conclude on the statement below it.
public class StopLight
{ int RedGreenYellow;
changeLight()
{ RedGreenYellow++
} }
The methods in a class definition are named, self-contained blocks of code that typically
operate on the fields that appear in the:
a. Object definition b. Interface definition c. Class definition d. Function definition
Question 2 [20]
a. Name the operators : a. < b. ++ c. && d. ?:
2. Write the following in Java expression: + +√
3. What does the token „keyword‟ refer to, in the context of Java? Give an example.
4. Write the difference between length and length() functions.
5. Write two characteristics of a constructor.

2
6. What is an array? Write a statement to declare an integer array of 10 elements.
7. How can a class type variable support the accessing of members of a class?
8. Write a statement each to perform the following task on a string:
a. Extract the second last character of a word stored in the variable wd.
b. Check if the second character of a string str is in upper case.
9. Define: Instance variables.
10. Give the output of the following program segment:
String say=”Pharaoh-meant-King”;
tring ok= [Link](0,5).toLowerCase();
String wow=[Link](5).toLowerCase();
[Link](“ok = “+ok);
[Link](“wow = “+wow);

Section B (60 Marks)


Attempt any four questions from this section.
The answer in this section should consist of the Program either in BlueJ environment or any
program environment with Java as the base.
Each program should be written using variable description/Mnemonic codes so that the logic of the
program is clearly depicted.
Question 3 [15]
Design an overload method named pattern () to print the following patterns:
** Printing the pattern... ** ** Printing the pattern... **
1 A
26 BA
3 7 11 CBA
4 8 12 16 DCBA
EDCBA
FEDCBA

Question 4 [15]
Write a program to accept the year of graduation from school as an integer value from the user.
Using the binary search technique on the sorted array of integers given below, output the
message "Record exists" if the value input is located in the array. If not, output the message
"Record does not exist".
Sample Input:

n[0] n[1] n[2] n[3] n[4] n[5] n[6] n[7] n[8] n[9]

1982 1987 1993 1996 1999 2003 2006 2007 2009 2010

Question 5 [15]
Define a class to accept and store 10 strings into the array and print the strings with even
number of characters.
Sample Input:
Enter Strings:
Apple
Cat
Book
Cake
Candle
Strings with even number of characters:
Book
Candle

3
Question 6 [15]
Define a class called BookFair with the following description:

Data Members Purpose

String Bname stores the name of the book

double price stores the price of the book

Member
Purpose
Methods

BookFair( ) Constructor to initialize data members

void input( ) To input and store the name and price of the book

To calculate the price after discount. Discount is calculated as per the table
void calculate( )
given below

void display( ) To display the name and price of the book after discount

Price Discount

Less than or equal to ₹1000 2% of price

More than ₹1000 and less than or equal to ₹3000 10% of price

More than ₹3000 15% of price

Write a main method to create an object of the class and call the above member methods.
Question 7 [15]
Write a program in Java to accept a word. Pass it to a function magic(String str). The function
checks the string for the presence of consecutive letters. If two letters are consecutive at any
position then the function prints "It is a magic string", otherwise it prints "It is not a magic
string".
Sample Input: computer
Sample Output: It is not a magic string
Sample Input: DELHI
Sample Output: It is a magic string
Question 8 [15]
A number is said to be Duck if the digit zero is (0) present in it. Write a program to accept a
number and check whether the number is Duck or not. The program displays the message
accordingly. (The number must not begin with zero)
Sample Input: 5063 Sample Input: 7453
Sample Output: It is a Duck number. Sample Output: It is not a Duck number.

**************************
4

Common questions

Powered by AI

Boxing in Java is the automatic conversion of primitive types to their corresponding object wrapper classes (e.g., converting an 'int' to an 'Integer'). Unboxing is the reverse process. Explicit type conversion is manually converting one data type to another, while implicit type conversion is done automatically by the Java compiler. Unboxing can sometimes be considered a form of implicit conversion since it happens automatically when an object is needed as a primitive .

A binary search in Java requires a sorted array. It works by repeatedly dividing the search interval in half, comparing the target value to the middle element. If equal, the search concludes; if smaller, it continues in the left subarray; if larger, in the right subarray. Binary search is more efficient than linear search with a time complexity of O(log n), versus O(n) for linear search, making it much faster for larger datasets .

Java provides several methods for string transformations: 'substring()' extracts parts of a string; 'toLowerCase()' and 'toUpperCase()' change a string's case; 'replace()' swaps specified characters or sub-strings. These operations are crucial for data processing, allowing programs to manipulate and format textual data according to specific requirements or user input, enhancing flexibility and functionality in Java applications .

Local variables in Java are declared within methods and are accessible only within the method's scope. They are created when a method is called and destroyed when it exits. This limited scope reduces memory usage and minimizes side effects, as local variables do not affect the state outside their method. Global (or class-level) variables, however, persist throughout the program's execution and can be accessed by all class methods, but they increase the risk of unexpected changes in program state .

Iterative construction of patterns in Java through function overloading involves defining multiple methods with the same name but different parameters to print various patterns. For instance, methods named 'pattern()' could be overloaded to print numeric and alphabetic sequences differently. This allows flexible pattern generation, where the specific method called depends on input data types, enabling significant code reuse and abstraction .

The absence of a break statement in a Java switch-case structure causes control to 'fall through' the subsequent cases, executing them until a break is encountered or the switch ends. This can lead to logical errors if unintended cases execute, making the program behave unexpectedly. Such fall-through behavior can be used intentionally to execute multiple cases with the same outcome, but it requires careful control to avoid logic flaws .

In Java, the Math.abs() function returns the absolute value of a number, removing its sign. When you have a negative floating-point number and cast it to an integer, the fractional part is discarded. Therefore, combining Math.abs() with explicit type casting in the code 'double x= -3.142; int y =(int)Math.abs(x)+(int)x;' results in: Math.abs(-3.142) becomes 3.142, casting it to an integer truncates to 3, and casting x directly to an integer truncates -3.142 to -3. Adding these gives the output of 0 .

Constructors in Java have two primary characteristics: they have no return type, and their names match the class name. Constructors are special methods used to initialize objects and allocate resources during object creation. Unlike regular methods, constructors cannot be overridden, but they can be overloaded to provide multiple ways to instantiate an object. They set initial states for objects, making them fundamental for object-oriented programming .

Access specifiers in Java determine the visibility of class members. 'Private' restricts visibility to the class itself, providing the highest level of security. 'Protected' allows visibility to subclasses and classes within the same package, offering moderate security. 'Default' or 'friendly' access, with no modifier, restricts access to the package level, providing the least security compared to 'private' and 'protected'. These levels affect how classes expose their data and interfaces to other parts of an application .

The 'Object' class in Java is significant because it is the root of the class hierarchy; every class has 'Object' as a superclass. This means that all objects in Java inherit methods from the 'Object' class, such as 'toString()', 'equals()', and 'hashCode()'. It provides a basic set of functionalities that are required by all objects and serves as a base for type safety across the Java framework .

You might also like