0% found this document useful (0 votes)
2K views6 pages

Method Signature in Java Exam Paper

The document contains the details of a preparatory examination for Class X students of Clarence Public School in Bangalore, India. It provides instructions for the exam, which consists of 2 sections - Section A with 1 question containing 20 sub-questions, and Section B with 4 questions out of 8 to be answered. The questions are related to Computer Applications and cover topics like Java concepts, arrays, strings, methods etc. Students are required to write their answers on the paper provided separately within the allotted time of 2 hours.
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)
2K views6 pages

Method Signature in Java Exam Paper

The document contains the details of a preparatory examination for Class X students of Clarence Public School in Bangalore, India. It provides instructions for the exam, which consists of 2 sections - Section A with 1 question containing 20 sub-questions, and Section B with 4 questions out of 8 to be answered. The questions are related to Computer Applications and cover topics like Java concepts, arrays, strings, methods etc. Students are required to write their answers on the paper provided separately within the allotted time of 2 hours.
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
  • Question 1
  • Question 2
  • Question 3
  • Question 4
  • Question 5
  • Question 8
  • Question 7

CLARENCE PUBLIC SCHOOL

J. P. NAGAR, BANGALORE – 78.


FIRST PREPARATORY EXAMINATION DECEMBER- 2023
CLASS: X ICSE SUBJECT: COMPUTER APPLICATIONS
TIME: 2 hrs DATE: 21-12-2023 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 compares two operands and returns a boolean value.
(a) <= (b) = (c) + (d) . (dot)
(iii) _______ is a multi-way branch selection statement.
(a) if else (b) if else if (c) switch (d) if
(iv) Method of wrapper class that converts a numerical string to int value is _________.
(a) toInteger ( ) (b) parseInt ( ) (c) parseInteger ( ) (d) ParseINTEGER ( )
(v) The number of bytes occupied by an integer array of 10 elements is ______.
(a) 10 bytes (b) 20 bytes (c) 40 bytes (d) 60 bytes
(vi) The method of Scanner class used to accept a character is ________.
(a) next ( ) (b) next ( ).charAt (0) (c) nextLine ( ) (d) nextChar ( )
(vii) Java keyword that makes the variable as constant is _______.
(a) const (b) Final (c) final (d) int
1
(viii) The output of [Link] (9, 0.5) + [Link] (-3.8) is _______.
(a) 4.8 (b) 0.8 (c) 7.0 (d) 6.8
(ix) Name the type of error if any in the following statement.
int x=4.4;
[Link] (x);
(a) logical (b) syntax (c) runtime (d) no error
nd
(x) Java statement to access the 2 element of an array is _________.
(a) a[2] (b) a[3] (c) a[1] (d) a[0]
(xi) The output of "ICSE". compareTo ("CBSE") is ________.
(a) false (b) -6 (c) 6.0 (d) 6
(xii) Which of the following is valid array declaration ?
(a) int a[]=new int[5]; (b) a[] int=new a[5]; (c) int a[5]; (d) none
(xiii) Name the package that contains Double class.
(a) [Link] (b) [Link] (c) [Link] (d) [Link]
(xiv) Method overloading follows which principle of Object Oriented Programming?
(a) Inheritance (b) Polymorphism (c) Abstraction (d) Encapsulation
(xv) Which of the following Scanner class method can read a single word from the standard
input stream?
1. next ( )
2. nextWord ( )
3. nextLine ( )
4. readLine ( )
(a) Only 1 (b) 1 and 4 (c) 1 and 3 (d) 1 and 2
(xvi) The method indexOf (char) returns ______ when a character is unavailable in a string.
(a) false (b) 0 (c) 1 (d) -1
(xvii) Assertion (A): return statement transfers the control back to the calling place of a
method.
Reason (R): It is a jump statement.
(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
(xviii) Read the following text, and choose the correct answer.
A method/function prototype comprises of access specifier, modifier, return type,
method name and with/without parameters. Function signature is part of function
prototype which includes only the method name along with the parameters.
Identify the function signature from the given function prototype.
public static void calc (int x)
2
(a) public static void calc (int x) (b) int x (c) static void calc (int x) (d) calc (int x)
(xix) Assertion (A): An Array can store only single value.
Reason (R): It is a composite/reference datatype.
(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) What will be the output for:
[Link] ('A'+2+" is the output");
(a) A2 is the output (b) 99 is the output (c) 67 is the output (d) C is the output
Question 2
(i) Write the java expression for 𝑝2 + √𝑞 [2]
(ii) Evaluate the expression when the value of m=10; [2]
m*=--m + m-- + ++m;
(iii) The following code segment should print the factors of n, if the value of n is greater than
zero. However, the code has errors. Fix the code so that it compiles and runs correctly.
[2]
if (n>0)
{
for (int i=1;i>=n;i++)
{
if(i%n ==0)
[Link] (i);
}
}
(iv) Sharvil executes the following program segment to get the output as a last character from
the string x, 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 (String x)
{
int len=[Link] ( );
char c=[Link] (len);
[Link] ("Last character is "+c);
}

3
(v) How many times will the following loop execute? What will be the output? [2]
for (int i=10;i<=100;i+=10)
{
if(i%3!=0)
continue;
[Link] (i);
}
(vi) Write the output of the following String methods: [2]
(a) "CHROME".substring (2);
(b) "Classic".lastIndexOf ('C');
(vii) What are the two ways of invoking a method? [2]
(viii) Predict the output of the following code snippet. [2]
String a="14", b="12.5";
[Link] ([Link] (a));
[Link] ([Link] (0) == [Link] (0));
(ix) Name the following: [2]
(a) Name the variables that are common to all the objects of a class.
(b) At each stage, compares the sought key value with the key value of the middle
element of the array.
(x) int b[][]={{1,3},{5,7}}; [2]
(a) What will be the size of array b[][]?
(b) What is the value present at b[1][1]?

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 Grade_Revision having the following description:-
Instance Variables/Data Members:
String name - to store name of an employee
int bas - to store the basic salary
int expn - to store the years of service as experience
double inc - to store the increment
4
double nbas - to store the new basic salary (basic+increment)
Member Functions:
Grade_Revision ( ) - to intilalize name, bas, expn to their default values.
void input ( ) - to accept input for name, bas and expn.
[Using Scanner class only]
void compute ( ) - to calculate the increment with the following
specifications.
Experience Increment
Up to 3 years `1,000 + 10% of basic
More than 3 years and up to 5 years `3000 + 12% of basic
More than 5 years and up to 10 years `5,000 + 15% of basic
More than 10 years `8,000 + 20% of basic
Finally calculate the new basic salary as basic + Increment.
void display ( ) – print all the details of an employee.
Write a main ( ) method to create an object and call the functions.
Question 4
Define a class to search for a value input by the user from the list of values given below. If it
is found display the message "Search successful", otherwise display the message "Search
element not found” using Binary search technique.
5.6, 11.5, 20.8, 35.4, 43.1, 52.4, 66.6, 78.9, 80.0, 95.5.
Question 5 [15]
Define a class to accept a string and a character and convert both the string and the character
to lowercase and display the frequency of the character present in the string.
Example:
Input String: determination
Input Character: e
Output: The frequency of e is 2
Question 6 [15]
Define a class to input a number and check and print whether it is a Munchausen number or
not. A number is called Munchausen, if the sum of its digits raised to the power of itself is
equal to the input number.
Example:
Input number: 3435
Output: Munchausen number [33 + 44 + 33 + 55 = 3435]

5
Question 7 [15]
Define a class to accept integer values into 3x3 array and
(i) Print the reverse of an array in matrix format.
(ii) Find the average of ODD elements present in an array
Example:
Input: A[][]={{1,2,3},{4,5,6},{7,8,9}}
Output:
Reverse of an array
987
654
321
Average of ODD elements is 5.0 → (1+3+5+7+9)/5.0
Question 8 [15]
Define a class to overload the method print () as follows:
void print ( ) – To print the following pattern using nested for loop.
13579
1357
135
13
1
void print (int n) – print the square of all the even digits of the number ‘n’
Example:
If n is 172564
Output:
Squares of Even digits are:
16 →42
36 →62
4 →22
_________________

Common questions

Powered by AI

The 'next()' method of the Scanner class advances the scanner past the current word and returns the input. It is designed to read a single word delimited by whitespace. In contrast, 'nextLine()' reads everything until a line break, making it suitable for reading statements or sentences .

In Java, arrays are used to store multiple values of the same type, which makes them efficient for storing collections of similar data. However, arrays cannot store different data types unless using an array of objects, which may impact memory usage and require type casting for operations .

The feature of Java illustrated by having multiple methods with the same name but different parameters is called Polymorphism, specifically 'method overloading' .

A Munchausen number is a number equal to the sum of its digits each raised to the power of themselves. To verify if a number is Munchausen, one would sum the result of raising each digit to the power of itself and compare this sum to the original number .

The 'switch' statement is preferable over 'if-else' statements when dealing with multiple discrete cases that depend on a specific value of a variable; it provides a cleaner, more efficient way to execute different blocks of code based on the variable's value .

In Java, the 'final' keyword is used to declare constants. A variable marked as 'final' cannot be modified after it is initialized, effectively making it a constant . This differs from variables without the keyword, which can be changed throughout the program execution.

The increment is computed based on service years as follows: Up to 3 years, add 1,000 + 10% of basic; for 3 to 5 years, add 3,000 + 12% of basic; for more than 5 to 10 years, add 5,000 + 15% of basic; and for more than 10 years, add 8,000 + 20% of basic. These specifications require condition checks and arithmetic operations within a compute method .

To retrieve the last character of a string in Java, you should adjust the index to be 'x.length() - 1' in the charAt() method, as indexes start at 0. This corrects the error related to indexing beyond the length of the string .

Errors in Java can be categorized as syntax, runtime, and logical errors. The error in the statement 'int x=4.4; System.out.println (x);' is a syntax error because you are trying to assign a double value to an integer variable without explicit casting .

The output of 'System.out.println('A'+2+" is the output");' is '67 is the output' because 'A' is implicitly cast to its ASCII value (65), and 2 is added to it before concatenating with the string, demonstrating Java's operator precedence rules .

You might also like