0% found this document useful (0 votes)
532 views6 pages

Java Exam Paper for Class X ICSE

Uploaded by

lololololo
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)
532 views6 pages

Java Exam Paper for Class X ICSE

Uploaded by

lololololo
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

CLARENCE PUBLIC SCHOOL

J. P. NAGAR, BANGALORE – 78.


SECOND PREPARATORY EXAMINATION JANUARY- 2024
CLASS: X ICSE SUBJECT: COMPUTER APPLICATIONS
TIME: 2 hrs DATE: 24-01-2024 MARKS : 100
Total no. of questions: 08 No. of pages: 06
Answers 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 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
(Attempt all questions from this Section)
Question 1 [20]
Choose the correct answers to the questions from the given options:
(Do not copy the question, write the correct answers only.)
(i)

Name the feature of Java depicted in the above picture.


(a) Encapsulation (b) Inheritance (c) Abstraction (d) Polymorphism
(ii) Operator that works on single operand.
(a) Unary (b) Binary (c) Ternary (d) dot operator
(iii) Conditional branching statement used to select one alternative statement out of two.
(a) if (b) nested if (c) if else (d) switch
(iv) Wrapper class method to check whether the character ch is an alphabet:
(a) isApha (ch) (b) isLetter (ch) (c) isletter (ch) (d) isLETTER (ch)
(v) The number of bytes occupied by an integer array of size 3x3:
(a) 72 bytes (b) 9 bytes (c) 18 bytes (d) 36 bytes
(vi) The method of String class used to check the equality between two strings:
(a) equals (string) (b) Equals (String) (c) equalsTo (string) (d) equal (string)
(vii) Java keyword used to allocate memory space for an array:
(a) malloc (b) New (c) new (d) alloc
(viii) The output of [Link] (-2.5) + [Link] (-2.5) is:
(a) 5.0 (b) -5.0 (c) 5 (d) -5

1
(ix) Name the type of error if any in the following statement.
int a=25;
if(a%5==0)
[Link] ("not divisible by 5");
else
[Link] ("divisible by 5");
(a) syntax (b) runtime (c) logical (d) no error
th
(x) Java statement to access the 5 character from the string "GALAXY" is:
(a) char c="GALAXY".charAt (5); (b) char c="GALAXY".charAt (4);
(c) char c="GALAXY".Charat (4); (d) char c="GALAXY".charAt (6);
(xi) Predict the output:
char a[]={65, 66, 67, 68, 69};
[Link] (a[3]);
(a) 68 (b) d (c) D (d) C
(xii) Package that contains String class is:
(a) [Link] (b) [Link] (c) [Link] (d) [Link]
(xiii) Which unit of class gets invoked when an object is created?
(a) member method (b) member variable (c) constructor (d) static members
(xiv) The output of "Celebration".replace ('e', 'E'); is:
(a) CElEbration (b) CElebration (c) CelEbration (d) CeLeBRATION
(xv) Which of the following is used to check whether the character ch is a digit only?
1. isDigit (ch)
2. isLetterOrDigit (ch)
3. isNumber (ch)
4. IsDigit (ch)
(a) Only 1 (b) 1 and 2 (c) 2 and 3 (d) 2 and 4
(xvi) Assertion (A): The search key element is compared with every element of an array
from 0th index position.
Reason (R): It is a binary search method
(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)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
(xvii) What is the output produced by the following statement?
[Link] ("Answer is "+4+2);
(a) Answer is 6 (b) Answer is 42
(c) Answer is 24 (d) 42

2
(xviii) Read the following text, and choose the correct answer.
In Java, the source code is converted to byte codes by the compiler. The byte codes
generated can be used to execute in multiple platforms. The byte codes are
further converted to machine (object) codes by the interpreter. The interpreter used in
java is JVM (Java Virtual Machine).
Translator(s) used in java is:
(a) compiler (b) interpreter (c) both compiler and interpreter (d) assembler
(xix) Assertion (A): NOT ! operator reverses the outcome of an expression.
Reason (R): It is a logical operator.
(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)
(c) Assertion (A) is true and Reason (R) is false
(d) Assertion (A) is false and Reason (R) is true
(xx) The return datatype of [Link] ('A', 'a') is:
(a) char (b) int (c) double (d) boolean
Question 2
(i) Predict the output:- [2]
int a[][]={{0, 4, 6},{1, 5, 8}, {12, 9, 3}};
(a) [Link] ([Link]);
(b) [Link] (a[0][2]*a[1][1]+a[2][0]);
(ii) What is the difference between private and public access specifiers? [2]
(iii) How many times will the following loop execute? What will be the output? [2]
int x=10;
do
{
[Link] (x++);
[Link] (x);
}while(x>=15);
(iv) Write the java expression for: |𝑥 2 − 𝑦 2 | [2]
(v) The following code segment should print the sum of all the one digit integers from an
array x[] of size 10. However, the code has errors. Fix the code so that it compiles and
runs correctly. [2]
int x[]={4, 10, 125, 6, 2, 45, 66, 7, 15, 12};
int sum=1;
for (int i=0;i<[Link];i++)
{
if (x[i]<=1 && x[i]>=9)
sum=sum + x[i];
3
}
[Link] (sum);
(vi) Evaluate the expression when the value of a=10 and b=2 respectively. [2]
a+=++a + --b * --a;
[Link] (a);
[Link] (b);
(vii) Study the following code and answer the questions that follow: [2]
class purchase
{
String name;
double price;
public purchase (String n, double p)
{
name = n;
price = p;
}
}
Questions:-
1. Name the instance variables.
2. Write a java statement to invoke the member method (constructor).
(viii) Abdur executes the following program segment to get the output as product of even
numbers from 1 to n, but he is getting an error. Name the error (syntax/logical/runtime)
how the program can be modified to get the correct answer? [2]
public void find (int n)
{
int p=1;
for (int i=1, i<=n, i++)
{
if (i%2==0)
p=p*i;
}
[Link] ("Product of even numbers is "+p);
(ix) Write the output of the following String methods: [2]
(a) "DENOMINATION".substring (6, 12).toLowerCase ( );
(b) "ACCURACY".length ( );
(x) What is the result given by the following library methods: - [2]
1. [Link] ('g');
2. [Link] ('G');

4
SECTION B
(Answer 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 the base.
Each program should be written using variable description/mnemonic codes so that the logic
of the program is clearly depicted.
Flowcharts and algorithms are not required.
Question 3 [15]
Define a class shopping having the following description:-
Instance Variables/Data Members:
int code - to store the code of an item purchased
int price - to sore the price of an item purchased
int qty - to store the quantity (total number of items purchased)
int total_price - to store the total price (price x qty)
String gift - to store the gift to be presented
Member Functions:
void accept ( ) - to accept input for code, price and qty using Scanner class.
void calculate ( ) - to calculate the total price and assign the gift as per the following
Total Price Gift
`100 to `500 Key ring
`501 to `1000 Leather Purse
More than `1000 Pocket Calculator
void display ( ) - print the item code, total price and the gift presented.
Write a main ( ) method to create an object and call the functions.
Question 4 [15]
Define a class to accept 10 electronic products in a one dimensional array and sort them in
ascending order using bubble sort technique. Display the sorted array.
Question 5 [15]
Define a class to accept a string and group all the alphabets, digits and special characters
excluding whitespaces in three different strings and display.
Example:
Input String: Movie starts @ 4:00pm

5
Output: Moviestartspm
400
@:
Question 6 [15]
Define a class to input a number and check and print whether it is a xylem number or not. A
number is called xylem if the sum of extreme digits (first digit and last digit) equals the sum
of mean (all digits except first and last digit) digits.
Example:
Input number: 12225
Output: xylem number
Sum of first and last digit is 6 (1+5) Sum of mean digits is 6 (2+2+2)
6 equals 6 hence it’s a xylem number. Other xylem numbers are 12348, 825122,…………
Question 7 [15]
Define a class to accept integer values into 4x4 array and display the sum of even numbers in
each row.
Example:
Input:
A[][] ={ {2, 1, 3, 4},
{8, 2, 7, 5},
{6, 4, 4, 3},
{3, 2, 5, 2}
}
Output: Sum of even no’s in row 1 is 6
Sum of even no’s in row 2 is 10
Sum of even no’s in row 3 is 14
Sum of even no’s in row 4 is 4
Question 8 [15]
Define a class to overload the method display () as follows:
void display ( ) – To print the following pattern using nested for loop.
123456
234567
345678

void display (int n) – Prints the count of odd digits present in the given number.
Example:
If n is 12563
Output: Count of odd digits : 3
_________________

Common questions

Powered by AI

The method isDigit() in Java is part of the Character class and is used to test whether a specified character is a digit. This is crucial for input validation in Java applications, ensuring that inputs conform to expected formats (e.g., numeric input fields) and preventing type-related anomalies and potential errors during further processing . It helps maintain data integrity within applications by ensuring that only valid characters are processed as digits.

Java does not support operator overloading, which means operators such as +, -, *, and / cannot be redefined for user-defined types as in C++. This limitation keeps the language simpler and avoids the complexity that might arise from overloading operators for custom types, which can lead to less readable code if not used judiciously . Instead, Java provides method overloading as an alternative to achieve similar functionalities but without the directly intuitive syntax that operator overloading would provide in languages like C++.

Overloading methods in Java allows a class to have more than one method with the same name as long as their parameter lists differ. This enhances functionality by providing multiple ways to perform similar operations, thereby increasing the flexibility of a program. For instance, multiple versions of a display() method could exist: one without parameters to display default information, and another with various parameters to customize display based on input, adapting outputs based on different contexts or requirements .

A constructor in Java is a special method called when an instance of an object is created, which initializes the newly created objects. Constructors can set initial values for the object’s data fields and allocate resources. Unlike methods, constructors do not have a return type and their name matches the class name. They are essential for preparing the object to be in a usable state right after creation, ensuring all necessary properties are set .

The process involves the Java compiler converting the high-level Java source code into intermediate bytecode, which is platform-independent. This bytecode is then executed by the Java Virtual Machine (JVM), which interprets or compiles it into machine code specific to the host machine. This ability to execute the same bytecode on multiple platforms is central to Java's 'write once, run anywhere' capability, promoting software portability across different operating systems without modification .

The use of if-else statements is appropriate when conditions are significantly complex, involve relational operators, or when logical operators are necessary to express conditions. This offers great flexibility. Switch statements are preferable for variable comparison against constant values, especially when dealing with numerous discrete possible values such as menu selections or fixed categories. Switch statements generally lead to more readable code with potentially fewer lines for such scenarios .

Public access specifiers allow properties and methods to be accessible from outside the class, making them part of the class’s external interface. Private access specifiers restrict access to within the declaring class, thus protecting sensitive data and internal logic from external modification. This promotes encapsulation and information hiding, maintaining control over changes to the object’s state and reducing dependency on implementation details, thereby facilitating more secure and robust designs .

A logical error occurs when the program compiles and runs but does not produce the expected output due to a flaw in the algorithm or logic. For instance, using the wrong conditional statement can lead to logical errors. Conversely, runtime errors occur during the execution of the program and usually result from unexpected operations like division by zero or accessing invalid array indices . To mitigate logical errors, developers can conduct thorough algorithm design reviews, and extensive unit testing. Runtime errors can be reduced through robust input validation and exception handling mechanisms.

Using nested loops in Java is advantageous for iterating over multi-dimensional data structures or creating complex patterns, as it provides a simple structure for systematic data traversal and pattern generation. However, nested loops can potentially lead to higher time complexity, making the program inefficient with increased input size due to the repetitive nature of operations involved. It is important to ensure that the depth of nesting is necessary and optimized to avoid performance bottlenecks .

The feature of Java that is demonstrated is Encapsulation. Encapsulation in Java is a fundamental principle where data and functionality are bundled together within classes, allowing objects to maintain a clear interface and hide complex internal details. This is achieved using classes and access specifiers allowing the programmer to control the accessibility of data and methods .

You might also like