Icse 2024 Examination Specimen Question Paper Computer Applications
Icse 2024 Examination Specimen Question Paper Computer Applications
COMPUTER APPLICATIONS
The time given at the head of this Paper is the time allowed for writing the answers.
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)
(iv) When primitive data type is converted to a corresponding object of its class, it
is called:
(a) Boxing
(b) Unboxing
(a) 20 bytes
(b) 60 bytes
(c) 40 bytes
(vi) The method of Scanner class used to accept a double value is:
(a) nextInt()
(b) nextDouble()
(c) next()
(d) nextInteger()
(a) every
(b) all
(c) case
(d) each
(a) 9.0
(b) 11.0
(c) 10.0
(d) 11
System.out.print("HELLO")
(a) logical
(b) no error
(c) runtime
(d) syntax
(a) X[4]
(b) X[5]
(c) X[3]
(d) X[0]
(a) mark
(b) emark
(c) marka
(d) able
(a) String
(b) Char
(c) Character
(d) Float
(a) java.lang
(b) java.util
(d) java.awt
(a) Inheritance
(b) Polymorphism
(c) Abstraction
(d) Encapsulation
1. 4
2. 4.0
3. 4.3f
4. “four”
(a) Only 1.
(b) 1. and 3.
(c) 2. and 4.
(d) 1. and 2.
(a) true
(b) 0
(c) 1
(d) false
(vii) Assertion(A): In java statements written in lower case letter or upper case letter
are treated as the same.
(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)
(xviii) Read the following text, and choose the correct answer:
(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)
(a) 0
(b) 1
(c) A
(d) true
Question 2
(iii) The following code segment should print “You can go out” if you have done [2]
your homework (dh) and cleaned your room(cr). However, the code has errors.
Fix the code so that it compiles and runs correctly.
boolean dh = True;
boolean cr= true;
if (dh && cr)
System.out.println("You cannot go out");
else
System.out.println("You can go out");
(v) How many times will the following loop execute? What value will be returned? [2]
int x=2;
int y=50;
do{
++x;
y-=x++;
}
while(x<=10);
return y;
(ix) When there is no explicit initialization, what are the default values set for [2]
variables in the following cases?
(a) Integer variable
(b) String variable
SECTION B
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.
Question 3 [15]
Define a class to accept values in integer array of size 10. Sort them in an ascending order
using selection sort technique. Display the sorted array.
Question 5 [15]
Define a class to accept a string and convert it into uppercase. Count and display the
number of vowels in it.
Input: robotics
Output: ROBOTICS
Number of vowels: 3
Question 6 [15]
Define a class to accept values into a 3×3 array and check if it is a special array. An array
is a special array if the sum of the even elements = sum of the odd elements.
Example:
A[][]={{ 4 ,5, 6}, { 5 ,3, 2}, { 4, 2, 5}};
Sum of even elements = 4+6+2+4+2 =18
Sum of odd elements= 5+5+3+5=18
Question 7
Define a class to accept a 3 digit number and check whether it is a duck number or not. [15]
Note: A number is a duck number if it has zero in it
Example1:
Input: 2083
Output: Invalid
Example 2:
Input: 103
Output: Duck number
The time given at the head of this Paper is the time allowed for writing the answers.
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[ ].
Question 1 [20]
Choose the correct answers to the questions from the given options.
(Do not copy the questions, write the correct answers only.)
(i)
Consider the above picture and choose the correct statement from the following:
(a) b
(b) A
(c) B
(d) 97
(a) 9
(b) 7
(c) 6
(d) (-1)
(a) package
(b) public
(c) protected
(d) private
(a) 11
(b) –11
(c) 0
(d) 13
(a) /n
(b) \t
(c) /t
(d) //n
T24 861 2
(a) b
(b) c
(c) a
(a) 10.0
(b) 11.0
(c) 12.0
(d) 9.0
(a) isDigit(char)
(b) isLetterOrDigit()
(c) isLetterOrDigit(char)
(d) isLETTERorDIGIT(char)
(a) exe
(b) obj
(c) jvm
(d) java
(xi) The number of bytes occupied by a character array of four rows and three
columns are:
(a) 12
(b) 24
(c) 96
(d) 48
(a) int
(b) char
(c) String
(d) double
1. for
2. while
3. do..while
4. switch
(a) only 1
(b) 1 and 2
(c) 1 and 3
(d) 3 and 4
(c) Constructor
(d) Destructor
(xv) If the name of the class is “Yellow”, what can be the possible name for its
constructors?
(a) yellow
(b) YELLOW
(c) Yell
(d) Yellow
T24 861 4
(xvii) The correct statement to create an object named mango of class fruit:
(xviii) Assertion (A): Static method can access static and instance variables.
System.out.println(color[2].length());
(a) 6
(b) 5
(c) 3
(d) 2
(a) Math.ceil(n)
(b) Math.sqrt(n)
(c) Math.floor(n)
(d) Math.round(n)
Question 2
(i) Write Java expression for: [2]
|𝑎𝑎 + 𝑏𝑏|
√𝑎𝑎2 + 𝑏𝑏 2
x + = x + + * + + x % 2;
(iii) Rewrite the following do while program segment using for: [2]
x = 10; y = 20;
do
x++;
y++;
} while (x<=20);
System.out.println(x * y );
(iv) Give the output of the following program segment. How many times is the loop [2]
executed?
for(x=10; x>20;x++)
System.out.println(x);
System.out.println(x*2);
T24 861 6
double d1=Double.parseDouble(s1);
double d2=Double.parseDouble(s2);
int x= (int)(d1+d2);
What is value of x?
(vi) Consider the following two-dimensional array and answer the questions given [2]
below:
(viii) The following code to compare two strings is compiled, the following syntax [2]
error was displayed – incompatible types – int cannot be converted to boolean.
Identify the statement which has the error and write the correct statement. Give
the output of the program segment.
void calculate()
boolean x = a.compareTo(b);
System.out.println(x);
(ix) Consider the given program and answer the questions given below: [2]
class temp
int a;
temp()
a=10;
temp(int z)
a=z;
void print()
System.out.println(a);
void main()
t.print();
x.print();
(a) What concept of OOPs is depicted in the above program with two
constructors?
(x) Primitive data types are built in data types which are a part of the wrapper [2]
classes. These wrapper classes are encapsulated in the java.lang package. Non
primitive datatypes like Scanner class are a part of the utility package for which
an object needs to be created.
(b) Write the statement to access the Scanner class in the program.
T24 861 8
Question 3 [15]
DTDC a courier company charges for the courier based on the weight of the parcel. Define
a class with the following specifications:
void accept ( ) – to accept the details using the methods of the Scanner class only.
void main ( ) – to create an object of the class and invoke the methods
void perform (int r, int c) Use NESTED FOR LOOP to generate the
following format
r = 4, c = 5 output – 12345
12345
12345
12345
void perform (int m, int n, char ch) to print the quotient of the division of m and
n if ch is Q else print the remainder of the
division of m and n if ch is R
Question 5 [15]
Define a class to accept a number from user and check if it is an EvenPal number or not.
(The number is said to be EvenPal number when number is palindrome number (a number
is palindrome if it is equal to its reverse) and sum of its digits is an even number.)
Example: 121 – is a palindrome number
Sum of the digits – 1+2+1 = 4 which is an even number
Question 6 [15]
Define a class to accept values into an integer array of order 4 x 4 and check whether it is
a DIAGONAL array or not. An array is DIAGONAL if the sum of the left diagonal
elements equals the sum of the right diagonal elements. Print the appropriate message.
Example:
3 4 2 5 Sum of the left diagonal elements =
2 5 2 3 3 + 5 + 2 + 1 = 11
5 3 2 7 Sum of the right diagonal elements =
1 3 7 1 5 + 2 + 3 + 1 = 11
T24 861 10
Define a class pin code and store the given pin codes in a single dimensional array. Sort
these pin codes in ascending order using the Selection Sort technique only. Display the
sorted array.
Question 8 [15]
Define a class to accept the gmail id and check for its validity.
A gmail id is valid only if it has:
@
. (dot)
gmail
com
Example: [email protected] is a valid gmail id.
T24 861 11
h i P ra c t i c e
# S a a i !
Zar o o r i H
National
Best-selling
Publisher
Books:
Question Banks & Sample Papers BUY
Latest Syllabus & Paper Pattern at special discount
www.educart.co
COMPUTER APPLICATIONS
The time given at the head of this Paper is the time allowed for writing the answers.
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[ ].
Question 1 [20]
Choose the correct answers to the questions from the given options.
(Do not copy the questions, write the correct answers only.)
(i) A mechanism where one class acquires the properties of another class:
(a) Polymorphism
(b) Inheritance
(c) Encapsulation
(d) Abstraction
(a) ternary
(b) unary
(c) logical
(d) relational
(a) next()
(b) nextLine()
(c) Next()
(d) nextString()
(a) extends
(b) export
(c) import
(d) package
(a) 16.0
(b) 16
(c) 4.0
(d) 5.0
(vi) The absence of which statement leads to fall through situation in switch case
statement?
(a) continue
(b) break
(c) return
(d) System.exit(0)
(a) finite
(b) infinite
(c) null
(d) fixed
T23 861 2
(viii) Write a method prototype name check() which takes an integer argument and
returns a char:
(a) char check()
(b) void check (int x)
(c) check (int x)
(d) char check (int x)
(ix) The number of values that a method can return is:
(a) 1
(b) 2
(c) 3
(d) 4
(x) Predict the output of the following code snippet: String P = "20", Q ="22";
int a = Integer.parseInt(P);
int b = Integer.valueOf(Q);
System.out.println(a+""+b);
(a) 20
(b) 20 22
(c) 2220
(d) 22
(xi) The String class method to join two strings is:
(a) concat(String)
(b) <string>.joint(string)
(c) concat(char)
(d) Concat()
(xii) The output of the function "COMPOSITION".substring(3, 6):
(a) POSI
(b) POS
(c) MPO
(d) MPOS
T23 861 3 Turn Over
(xiii) int x = (int) 32.8; is an example of __________ typecasting.
(a) implicit
(b) automatic
(c) explicit
(d) coercion
(xvi) Consider the following program segment and select the output of the same
when n = 10 :
switch(n)
{case 10 : System.out.println(n*2);
case 4 : System.out.println(n*4); break;
default : System.out.println(n);
}
20
(a)
40
10
(b)
4
(c) 20, 40
10
(d)
10
T23 861 4
(xvii) A method which does not modify the value of variables is termed as:
(a) Impure method
(b) Pure method
(c) Primitive method
(d) User defined method
(xx) Method which is a part of a class rather than an instance of the class is termed
as:
(a) Static method
(b) Non static method
(c) Wrapper class
(d) String method
Question 2
(i) Write the Java expression for (𝑎𝑎 + 𝑏𝑏)𝑥𝑥 . [2]
T23 861 6
(x) Write the value of n after execution: [2]
char ch ='d';
int n = ch + 5;
Question 3 [15]
Design a class with the following specifications:
Class name: Student
Member variables: name – name of student
age – age of student
mks –marks obtained
stream – stream allocated
(Declare the variables using appropriate data types)
Member methods:
void accept() – Accept name, age and marks using methods of Scanner class.
void allocation() – Allocate the stream as per following criteria:
mks stream
> = 300 Science and Computer
> = 200 and < 300 Commerce and Computer
> = 75 and 200 Arts and Animation
< 75 Try Again
void print() – Display student name, age, mks and stream allocated.
Call all the above methods in main method using an object.
Question 4 [15]
Define a class to accept 10 characters from a user. Using bubble sort technique arrange
them in ascending order. Display the sorted array and original array.
Question 6 [15]
Define a class to accept a String and print the number of digits, alphabets and special
characters in the string.
Example: S = “KAPILDEV@83”
Output: Number of digits – 2
Number of Alphabets – 8
Number of Special characters – 1
Question 7 [15]
Define a class to accept values into an array of double data type of size 20. Accept a double
value from user and search in the array using linear search method. If value is found
display message “Found” with its position where it is present in the array. Otherwise
display message “not found”.
Question 8 [15]
Define a class to accept values in integer array of size 10. Find sum of one digit number
and sum of two digit numbers entered. Display them separately.
Example: Input: a[ ] = {2, 12, 4, 9, 18, 25, 3, 32, 20, 1}
Output: Sum of one digit numbers : 2 + 4 + 9 + 3 + 1 = 19
Sum of two digit numbers : 12 + 18 + 25 + 32 + 20 = 107
T23 861 8
COMPUTER APPLICATIONS
(Theory)
(Two Hours)
The time given at the head of this Paper is the time allowed for writing the answers.
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[].
Question 1.
(a) Define abstraction. [2]
(c) Write a difference between the functions isUpperCase( ) and toUpperCase( ). [2]
(d) How are private members of a class different from public members? [2]
(i) char
(ii) arrays
(iii) int
(iv) classes
(b) State the difference between while and do while loop. [2]
System.out.println("OF LUCK");
Choose the correct option for the output of the above statements
(ii) BEST
OF LUCK
(d) Write the prototype of a function check which takes an integer as an argument [2]
and returns a character.
(e) Write the return data type of the following function. [2]
(i) endsWith()
(ii) log()
Question 3.
(a) Write a Java expression for the following: [2]
√3𝑥 + 𝑥 2
𝑎+𝑏
(b) What is the value of y after evaluating the expression given below? [2]
y+= ++y + y-- + -- y; when int y=8
T18 861 2
(ii) "DEDICATE".compareTo("DEVOTE")
(h) Consider the following String array and give the output [2]
System.out.println(arr[0].length()> arr[3].length());
System.out.print(arr[4].substring(0,3));
(j) Give the output of the following program segment and also mention how many [2]
times the loop is executed:
int i;
for ( i = 5 ; i > 10; i ++ )
System.out.println( i );
System.out.println( i * 4 );
Question 4.
Design a class RailwayTicket with following description: [15]
Member methods :
void accept () – To take input for name, coach, mobile number and amount.
Write a main method to create an object of the class and call the above member
methods.
T18 861 4
Write a program to input a number and check and print whether it is a Pronic number [15]
or not. (Pronic number is the number which is the product of two consecutive integers)
Examples: 12 = 3 4
20 = 4 5
42 = 6 7
Question 6.
Write a program in Java to accept a string in lower case and change the first letter of [15]
every word to upper case. Display the new string.
Question 7.
Design a class to overload a function volume() as follows: [15]
(i) double volume (double R) – with radius (R) as an argument, returns the volume
of sphere using the formula.
V = 4/3 22/7 R3
(ii) double volume (double H, double R) – with height(H) and radius(R) as the
arguments, returns the volume of a cylinder using the formula.
V = 22/7 R2 H
(iii) double volume (double L, double B, double H) – with length(L), breadth(B) and
Height(H) as the arguments, returns the volume of a cuboid using the formula.
V=LBH
Write a menu driven program to display the pattern as per user’s choice.
Question 9.
[15]
Write a program to accept name and total marks of N number of students in two single
subscript array name[ ] and totalmarks[ ].
T18 861 6
(Theory)
(Two Hours)
The time given at the head of this Paper is the time allowed for writing the answers.
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[].
Question 1.
(a) What is inheritance? [2]
(c) State the number of bytes occupied by char and int data types. [2]
(c) State the data type and value of res after the following is executed: [2]
char ch='t';
res= Character.toUpperCase(ch);
(d) Give the output of the following program segment and also mention the number [2]
of times the loop is executed:
int a,b;
for (a = 6, b = 4; a <= 24; a = a + 6)
{
if (a%b ==0)
break;
}
System.out.println(a);
(e) Write the output: [2]
char ch = 'F';
int m = ch;
m=m+5;
System.out.println(m + " " + ch);
Question 3.
(a) Write a Java expression for the following: [2]
ax5 + bx3+c
T17 861 2
Question 5.
Write a program to accept a number and check and display whether it is a spy number [15]
or not. (A number is spy if the sum of its digits equals the product of its digits.)
Example: consider the number 1124, Sum of the digits = 1 + 1 + 2 + 4 = 8
Product of the digits = 1 1 2 4 = 8
T17 861 4
Question 7.
Write a program to input integer elements into an array of size 20 and perform the [15]
following operations:
(i) Display largest number from the array.
(ii) Display smallest number from the array.
(iii) Display sum of all the elements of the array.
Question 8.
Design a class to overload a function check( ) as follows: [15]
(i) void check (String str , char ch ) - to find and print the frequency of a character
in a string.
Example :
Input: Output:
str = "success" number of s present is =3
ch = 's'
(ii) void check(String s1) - to display only vowels from string s1, after converting
it to lower case.
Example :
Input:
s1 ="computer" Output : o u e
Question 9.
Write a program to input forty words in an array. Arrange these words in descending [15]
order of alphabets, using selection sort technique. Print the sorted array.
T17 861 5
This document of the Analysis of Pupil Performance at the ICSE (Class-10) Examination is a
unique tool for retrospection for both, teachers and students. It has grown and evolved over
the years to provide feedback to all concerned in terms of the strengths and weaknesses of the
candidates in handling the ICSE examinations.
We commend the work of Mrs. Shilpi Gupta and the team at the RDCD who have
painstakingly prepared this analysis. We are grateful to the examiners who have contributed
through their comments on the performance of the candidates under examination as well as
for their suggestions to teachers and students for the effective transaction of the syllabus.
We hope the schools will find this document useful in more ways than one. We invite
comments from schools on further improving its utility and quality.
Gerry Arathoon
November, 2016 Chief Executive & Secretary
Shilpi Gupta
November, 2016 Deputy Head - RDCD
STATISTICS AT A GLANCE
Total Number of students who took the examination 99,856
Highest Marks Obtained 100
Lowest Marks Obtained 27
Mean Marks Obtained 83.28
70.00 61.11
60.00
Percentage of Candidates
50.00
40.00 29.37
30.00
20.00 9.47
0.00 0.05
10.00
0.00
0-20 21-40 41-60 61-80 81-100
Marks Obtained
239
ANALYSIS OF PERFORMANCE
Question 1.
(a) Define Encapsulation. [2]
(b) What are keywords? Give an example. [2]
(c) Name any two library packages. [2]
(d) Name the type of error ( syntax, runtime or logical error ) in each case given below: [2]
(i) Math.sqrt (36 – 45)
(ii) int a;b;c;
(e) If int x [ ] = { 4, 3 , 7, 8, 9, 10}; what are the values of p and q? [2]
(i) p = x.length
(ii) q= x[2] + x[5] * x[1]
Comments of Examiners
1. Suggestions for teachers
(a) A number of candidates answered correctly.
However, some candidates confused Basic principles such as
Encapsulation with Data abstraction. Encapsulation, Polymorphism etc.
(b) Examples of keywords were written in capital should be explained properly with
letters. For example, This, New, Public …. etc. examples.
(c) Majority of candidates wrote the full word instead Explain the importance of case
of the name of the package. For example, utility sensitivity while writing keywords.
was written instead of util. Difference between class and
(d) Many candidates were confused between runtime package must be explained with
and logical errors and therefore wrote incorrect examples.
answers. Explain different types of errors
(e) The first part was answered correctly by most with examples on the computer with
candidates. In the second part of the question clear cut differences.
some candidates were not clear about index Calculation of length of an array and
position of the array and hence used wrong values retrieving an element from a given
for calculation of the answer. array should be practiced.
240
(b) Keywords are the words that convey a special meaning to the language Compiler. These are
reserved for special purpose and must not be used as normal identifiers.
(Correct explanation with an example)
(c) java.io.* or io package
java.util.* or util package
(Any 2 library packages)
(d) (i) Runtime error
(ii) Syntax error
(e) (i ) 6
(ii) 37
Question 2.
(a) State the difference between == operator and equals ( ) method . [2]
(b) What are the types of casting shown by the following examples: [2]
(i) char c = (char)120;
(ii) int x = 't';
(c) Differentiate between formal parameter and actual parameter. [2]
(d) Write a function prototype of the following : [2]
A function PosChar which takes a string argument and a character argument and returns
an integer value.
(e) Name any two types of access specifiers. [2]
241
(a) Most candidates answered correctly. However, Give examples of the use of ==
some candidates confused == operator with operator and equals () method and
assignment operator. practice exercise questions based on
(b) Some candidates were unsure of the answer. They the above topics.
seem to have overlooked the mention of (char)120 Explain each type of conversion with
in the question and therefore interchanged the proper examples and point out the
answers. difference between them.
(c) A number of candidates were confused between Explain the terms such as formal
formal parameters and actual parameters. parameters and actual parameters and
(d) Many candidates were unable to write the illustrate them with several examples
function prototype. Some did not use the same Explain various parts of a function
variable name as mentioned in the question. with different examples. Make it
(e) Most candidates answered correctly. clear that the formal parameters
require data types and variable
names.
Students should be reminded
constantly about the importance of
case sensitivity while writing
keywords.
MARKING SCHEME
Question 2.
(a) == is an operator which is used to check the equality between primitive data type
equals () function checks the equality between Strings
(b) (i) explicit type casting
(ii) implicit type casting
(c) Actual parameter : The parameter which is present in the function call statement is called
actual parameter. It stores the original value.
Formal parameter : The parameter which is present in function prototype or function
signature is called formal parameter. It stores the duplicate value.
(d) int PosChar( String s, char ch)
242
243
244
(e) System.out.println((x%2==0)?"EVEN":"ODD");
245
Comments of Examiners
4. Many candidates answered this question Suggestions for teachers
correctly. Some common errors found were: Train students to use the same names
(i) Using a different class name than the one given for variables and methods as given in
in the question. the question.
(ii) constructor syntax was incorrect (return type Constructor syntax to be explained
void was used, variables were declared inside comprehensively with additional
revision and practice on writing
the constructor). constructors.
(iii) A single function was used instead of the one Programs on multiple functions of all
asked for in the question. types to be revised on a consistent
(iv) Price after discount was not calculated. basis.
(v) Use of ≤ and ≥ instead of the operators < = and Guide and instruct students to
>= , using commas in numbers convert English statements having
(vi) Some candidates wrote input method with conditions with ranges to JAVA
if…else statements using proper
parameters but got confused with the local and relational operators.
global variables. Advise students, in school exams
(vii) Syntax for object creation and function call against using ≤ and ≥ instead of < =
were incorrect. and >=.
Difference between global and local
variables and how to use them in
multiple function programs should be
explained clearly in class.
Creation of an object and invoking
methods using the object need to be
practiced thoroughly.
246
247
Comments of Examiners
5. Common errors made by candidates while Suggestions for teachers
attempting this question were:
(i) Menu not displayed or choice not input. Menu driven programs using switch
(ii) Wrote two separate programs instead of one. …case should be practiced in class.
(iii) Syntax of switch and default statements were The significance of break and default
wrong. statements should be explained.
(iv) Forgot to write break statement. Adequate examples and exercise
(v) Using println() in place of print() and vice versa. questions based on loop concept and
(vi) The patterns were obtained with multiple print nested loop must be given in class.
statements row after row. Method of extracting character
should be explained to candidates.
Other mistakes observed were:
(i) Candidates printed the loop variable instead of
using a counter and using it for printing the output.
(ii) Candidates did not know how to extract a letter from a string.
248
249
Comments of Examiners
Suggestions for teachers
6. Most candidates assigned a value given in the
example instead of accepting it from the user. Other Advise students to read the question
mistakes were: carefully.
(i) Initial and final values of the loop were wrong. Index value of the string starts from
(ii) Instead of applying proper logic to reverse a zero is an important point that must
word the library function reverse (). be explained with examples.
(iii) Extraction of the first and the last character of the All commonly used functions must
string was incorrect. be taught using examples.
(iv) Candidates wrote the program for a palindrome The difference between String
number. reverse and number reverse must be
taught.
250
Question 7.
251
MARKING SCHEME
Question 7.
import java.util.*;
class Q7 {
void SumSeries(int n, double x) {
double sum=0.0d;
int i;
for(i=1;i<=n;i++)
{ if (i%2==0 )
sum=sum-x/(double)i;
else
sum=sum+x/(double)i; }
System.out.println("sum="+sum); }
void SumSeries() {
int s=0, p=1;
for(int i=1;i<=20;i++) {
p=p*i;
s=s+p; }
System.out.println("sum="+s); }
public static void main(String args[]) {
Q7 obj=new Q7();
obj.SumSeries(5,2.0);
obj.SumSeries();
}}}
252
Comments of Examiners
8. Most of the candidates answered this question
Suggestions for teachers
correctly. However, few common mistakes were
observed: Instruct students to read the question
(i) Duplicate value of the accepted number was not carefully.
done by most of the candidates. The program should be done
(ii) Extraction of digits was not done in a proper way. carefully and importance of having a
(iii) Loop control variable was not updated (num = duplicate copy of a number should be
num/10) explained to the students.
(iv) Variable sum to add all digits of the number was Guide students to extract digits from
not initialized. numbers with examples.
(v) Candidates checked whether the sum is divisible Difference between / and % should
by num, instead of checking whether num is be explained clearly.
divisible by sum.
MARKING SCHEME
Question 8.
import java.util.*;
class Niven
{ public static void main(String args[]) {
Scanner sc =new Scanner(System.in);
System.out.println("enter number");
int num=sc.nextInt( );
int n=num;
int rem;
int sum=0;
while(num>0)
{ rem=num%10;
sum=sum+rem;
num=num/10; }
if(n%sum==0)
System.out.println("Niven number");
else
System.out.println("not Niven Number");
} }
253
Comments of Examiners
9. Common errors found were: Suggestions for teachers
(i) Syntax error in declaring and initializing of
arrays. Solve number of problems on arrays
(ii) Double quotes were not used for any string having various data types.
values. Syntax for creation of an array as
(iii) Country name to be searched was not accepted well assigning values and accepting
from the user. input values in an array need to be
(iv) Incorrect limits of loop practiced with different examples.
For (int i=1; i<=7;i++)
(v) outputting of messages were incorrectly placed.
254
import java.util.*;
class wonders
{
public static void main(String args[])
{
String w[]={"CHICHEN ITZA","CHRIST THE REDEEMER", "TAJMAHAL", "GREATWALL
OF CHINA","MACHU PICCHU","PETRA","COLOSSEUM"};
String l[]={"MEXICO","BRAZIL","INDIA","CHINA","PERU","JORDAN","ITALY"};
String s;int i,len;
Scanner br=new Scanner(System.in);
System.out.println("Enter the name of the country to be searched for " );
s=br.nextLine();
len=w.length; // OR len = l.length;
boolean flag=false;
for (i=0;i<len;i++) // OR for( i=0;i<7;i++)
{
if(s.equalsIgnoreCase(l[i]))
{
System.out.println(l[i]+" - "+ w[i]);
flag =true; break;
}
}
if(flag== false)
OR
class Wonders
{
String w[]={"CHICHEN ITZA", "CHRIST THE REDEEMER", "TAJMAHAL", "GREATWALL
OF CHINA", "MACHU PICCHU", "PETRA", "COLOSSEUM"};
String L[]={"MEXICO","BRAZIL","INDIA","CHINA" ,"PERU","JORDAN","ITALY"};
String s;
Wonders(String x)
{
s = x;
}
public void search ( )
{
255
256
257
November 2015
FOREWORD
This document of the Analysis of Pupil Performance at the ICSE (Class-10) Examination is a unique tool for
retrospection for both, teachers and students. It has grown and evolved over the years to provide feedback to all
concerned in terms of the strengths and weaknesses of the candidates in handling the ICSE examinations.
We commend the work of Mr. Lancelot J Fuller, Deputy Secretary, and the ICSE Division of the Council who
have painstakingly prepared this analysis. We are grateful to the examiners who have contributed through their
comments on the performance of the candidates under examination as well as for their suggestions to teachers
and students for the effective transaction of the syllabus.
We hope the schools will find this document useful in more ways than one. We invite comments from schools
on further improving its utility and quality.
Gerry Arathoon
November 2015 Chief Executive & Secretary
The Council for the Indian School Certificate Examinations has published the “Analysis of Pupil Performance”
annually since 1994. This document is reviewed every year and changes are incorporated based on suggestions
received from various quarters which include experts in the field of education, Heads of Schools and teachers, in
order to make the analysis more useful and meaningful.
This document comprises both, a quantitative as well as a qualitative analysis of the performance of pupils at the
ICSE examinations. The Analysis of Pupil Performance has been carried out for the most studied subjects that
are largely ascribed to, by the schools. The purpose of this document is to give teachers and students a macro
view of the overall performance of all candidates who have taken the examination and examiners’ comments on
each question. It is hoped that this would enable teachers and students to understand the assessment of the ICSE
examinations better and help both, teachers and students, in the teaching – learning process, more effectively.
The qualitative analysis seeks to provide a transparent look at the assessment process in order to enhance the
effectiveness of the entire assessment procedure. Once the process of the evaluation of scripts is over, examiners
are requested to contribute detailed comments on the performance of candidates for each question. The
comments include the examiners’ response on what constitutes a good answer; common errors made by
candidates while answering the questions; the questions that appeal to students and the overall performance by
the students.
The quantitative analysis is based on the overall performance of all the students who took the examination. An
analysis of the percentage of students who obtained marks in different mark ranges is also included.
Mr. Richard Ellis, Mr. M.R. Felix, Mr. M. Gopal, Mr. C.M. Thomas, Mrs. Liza George, Mrs. Namita Bajaj,
Mrs. Desiree Tennent and Ms. Mansi Guleria are to be commended for their meticulous and diligent effort in
preparing this reference tool for both, teachers and students.
Lancelot J Fuller
November 2015 Deputy Secretary
iii
STATISTICS AT A GLANCE
Mark Range
Details
0-20 21-40 41-60 61-80 81-100
Number of Candidates 3 54 7,469 27,146 59,578
Percentage of Candidates 0.00 0.06 7.92 28.80 63.21
Cumulative Number 3 57 7,526 34,672 94,250
Cumulative Percentage 0.00 0.06 7.99 36.79 100.00
70.00 63.21
Percentage of Candidates
60.00
50.00
40.00
28.80
30.00
20.00
7.92
10.00
0.00 0.06
0.00
0-20 21-40 41-60 61-80 81-100
Marks Obtained
227
ANALYSIS OF PERFORMANCE
Question 1
(a) What are the default values of primitive data type int and float? [2]
(e) Name the wrapper classes of char type and boolean type. [2]
Examiners’ Comments
(a) Most candidates answered correctly.
However a few were not clear about the Suggestions for teachers
default value of float. Primitive data types should be taught
(b) Most candidates answered correctly. However with its default values.
some candidates got confused with the Principles and features of OOP’s
principles of OOP’s. should be explained clearly.
(c) Most candidates answered correctly. A few Correct definitions of terms used
candidates however wrote the rules for frequently should be explained
declaring an identifier. thoroughly.
(d) Though most candidates answered correctly, Explain the different types of literals
there were some who misunderstood the with examples.
question and wrote vague and incorrect Teach all the wrapper classes with the
answers. correct syntax.
(e) Most candidates wrote the first character of
wrapper classes in lower case letters instead of uppercase character.
MARKING SCHEME
Question – 1
(a) The default value of int is 0 and that of float is 0.0f
(b) Data Abstraction/Abstraction, Inheritance, Polymorphism, Message passing, Data
encapsulation/Encapsulation
(c) An identifier is a sequence of characters used to name variables , methods, classes,
packages and interfaces OR
They represent names of different components of a Java program.
(d) (i) floating point literal
(ii) character literal..
(iii) boolean literal.
(iv) String literal
(e) Character and Boolean
228
(b) Arrange the following primitive data types in an ascending order of their size: [2]
(i) char (ii) byte (iii) double (iv) int
(c) What is the value stored in variable res given below : [2]
double res = Math.pow("345".indexOf('5'),3);
(e) What are the values of a and b after the following function is executed , if the values
passed are 30 and 50:
void paws(int a ,int b)
{ a=a+b;
b=a-b;
a=a-b;
System .out.println(a+","+b); } [2]
Examiners’ Comments:
(a) Most candidates answered correctly, however
Suggestions for teachers
some candidates wrote the expression (q-p) instead
Practice exercise on ternary operator.
of its final value.
(b) Candidates got confused between the size of int Order of all data types with its size
and char. Some candidates wrote the answer in should be taught thoroughly.
descending order instead of an ascending order. Stress on using important keywords.
(c) Most candidates wrote the answer as 8 instead 8.0. Practice exercises on evaluation of the
A few candidates were unable to find the index of multiple and single mathematical
the given argument. functions on the computer.
(d) Most candidates answered correctly. A few Constructor should be taught in detail
candidates were not clear about the types of along with its types.
constructor. Explain the difference between transfer
(e) Most candidates answered correctly. Some of value and interchange of value.
however were unable to interchange the value
correctly.
229
Question 3
(a) State the data type and value of y after the following is executed :
char x='7';
y= Character.isLetter(x); [2]
(b) What is the function of catch block in exception handling ? Where does it appear in
a program? [2]
(c) State the output when the following program segment is executed :
String a="Smartphone", b="Graphic Art";
String h=a.substring(2,5);
String k= b.substring(8).toUpperCase();
System.out.println(h);
System.out.println(k.equalsIgnoreCase(h)) ; [2]
(d) The access specifier that gives the most accessibility is____________________ and the
least accessibility is __________________. [2]
(e) (i) Name the mathematical function which is used to find sine of an angle given
in radians.
(ii) Name a string function which removes the blank spaces provided in the prefix
and suffix of a string . [2]
230
Examiners’ Comments
(a) Many candidates did not write the data type with
Suggestions for teachers
only the value being written. Some candidates
were unfamiliar with Character functions. All the character functions given in the
(b) Most candidates showed a lack of knowledge of Syllabus should be taught
this topic. However a few candidates wrote the comprehensively.
answer correctly. Teach all the String functions
(c) Many candidates answered this question mentioned in the syllabus thoroughly.
correctly. However some candidates incorrectly Access specifiers should be taught with
wrote (Art) instead of art. examples.
(d) Most candidates answered correctly. However, Emphasize on all mathematical and
there were few candidates who interchanged the String Functions.
answer. Some candidates wrote protected, friendly Attach more importance to the
and default as the answer instead of private. fundamentals of array.
(e) Most candidates answered this question Introduce the concept of packages and
correctly. A few however committed errors in the the classes contained in them.
syntax and wrote the answer as sine () instead of Practice output questions involving
sin (). loops and stress on doing dry run and
(f) Most candidates were unable to understand both writing the steps of calculation.
parts of the question and wrote incorrect answers. Explain the hierarchy of operators and
(g) Many candidates answered this question correctly. also how to evaluate the Java
A few candidates were not familiar with the expressions.
package that contains Scanner and Buffered class. Prefix and postfix of increment and
(h) A number of candidates wrote the answer correctly, decrement operator is a common topic
but a few candidates failed to take the last iteration. and sufficient practice must be done in
Some candidates wrote the integer value instead of class.
character value.
231
MARKING SCHEME
Question - 3
(a) Data type is boolean and y=false
(b) A Catch block is a group of Java statements that are used to handle a raised exception. The catch
block should be placed after try block.
(c) art
true
(d) (i) public (ii) private.
(e) (i)sin() (ii) trim()
(f) (i) garbage value
(ii) this keyword.
(g) io and util package
(h) a b c d
(i) (Math.pow(a,2)+Math.pow(b,2))/(2*a*b) [OR]
(a*a+b*b)/(2*a*b)
(j) int z=(++y*(y++ +5));
(11*(11+5));
176
Question 4
Define a class called Parking Lot with the following description :
Instance variables/data members :
int vno - To store the vehicle number
int hours - To store the number of hours the vehicle is parked in the parking lot
double bill - To store the bill amount
Member methods :
void input() - To input and store the vno and hours.
void calculate() - To compute the parking charge at the rate of 3 for the first hour or part thereof,
and 1.50 for each additional hour or part thereof.
void display() - To display the detail
Write a main method to create an object of the class and call the above methods.
[15]
232
MARKING SCHEME
Question - 4
import java.util.*;
class ParkingLot
{
int vno;
int hours;
double bill;
Scanner sc=new Scanner(System.in);
void input()
{
System.out.println("Enter the vehicle number and number of hours");
vno=sc.nextInt();
hours=sc.nextInt();
}
void calculate()
{
if(hours<=1)
bill= 3;
else
bill=3+(hours-1)*1.50;
}
void display()
{
System.out.println("Vechicle Number:"+vno);
System.out.println("Hours:"+hours);
System.out.println("Bill:"+bill);
}
public static void main(String args[])
{
ParkingLot pl=new ParkingLot();
233
Question 5
Write two separate programs to generate the following patterns using iteration(loop) statements:
* (b) 54321
*# 5432
*#* 543
*#*# 54
*#*#* 5 15]
Examiners’ Comments:
Suggestions for teachers
(i) Some candidates wrote the program for only one
type of triangle instead of both. Emphasize the difference between
(ii) A few candidates were confused with the print() and println() method.
pattern using two characters. Students should be made to practice and
(iii) In part (b) reverse loop was not formed execute programs to print patterns on
correctly the computer.
(iv) A few candidates answered this question by Assign program segments to students
writing 5 print statements. to find the output so that they will be
(v) Improper output, println() statement instead of able to perform the manual calculation
print() statement for printing each character. and understand how the loop works.
(vi) Blank println() statement was missing. Instruct students to dry run the program
MARKING SCHEME
Question - 5
(a) import java.io.*;
class Quest_5a
{
void patteren1()
{ for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{ if(j%2!=0)
System.out.print("*"+" ");
else
System.out.print("#"+" ");
}
234
Question 6
Write a program to input and store roll numbers, names and marks in 3 subjects of n
number students in five single dimensional array and display the remark based on
average marks as given below:(the maximum marks in the subject are 100)
average marks=Total Marks
3
Average marks Remarks
85-100 EXCELLENT
75-84 DISTINCTION
60-74 FIRST CLASS
40-59 PASS
Less than 40 POOR [15]
Examiners’ comments:
(i) Many candidates attempted the question without
Suggestions for teachers
using array.
(ii) Input of data was not taken inside the loop. Array creation with different data types
(iii) Value of ‘n’ (number of students) not accepted. should be practiced.
(iv) Arrays were declared without specifying the Inputting and storing elements in an
size. array should be practiced on the
(v) Calculation average was not done inside the loop. computer.
(vi) Accepted the average marks from the user Use of relational operators should be
instead of computing. explained clearly.
(vii) Conditions for grading were not written correctly.
235
236
237
MARKING SCHEME
Question - 7
import java.util.*;
class Quest_7
{
void joystring(String s,char ch1,char ch2)
{
String str=s.replace(ch1,ch2);
System.out.println(str);
}
void joystring(String s)
{
int first=s.indexOf(' ');
System.out.println("First index :"+first);
int last=s.lastIndexOf(' ');
System.out.println("Last index :"+last);
}
void joystring(String s1,String s2)
{ String s3=" ";
String str=s1.concat(s3).concat(s2);
System.out.println(str);
}
public static void main(String args[])
{
Quest_7 obj=new Quest_7();
obj.joystring("TECHNALAGY",'A','O');
238
Question 8
Write a program to input twenty names in an array. Arrange these names in descending order
of alphabets, using the bubble sort technique. [15]
Examiners’ comments
(i) Array elements are assigned not accepted. Suggestions for teachers
(ii) Integer array was declared instead of String Revise iteration before teaching arrays.
array. Explain the importance of the loop
(iii) Declaration of temporary variable as an integer variable.
type instead of String array. Basic technique such as searching and
(iv) Compare To() method was not used. sorting should be taught with different
(v) Other methods of sorting were used instead of data types.
bubble sort. Use of compareTo () method should be
(vi) Array elements were sorted in ascending order explained with help of examples.
instead of sorting in a descending order.
Train candidates to write the program
(vi) Printing of sorted elements was not done.
using different array length.
Difference between bubble sort and
selection sort must be discussed.
Emphasize on output requirements.
MARKING SCHEME
Question 8
import java.util.*;
class Quest_8
{ void sort()
{
Scanner br=new Scanner (System.in);
String names[]=new String[20];
System.out.println("Enter 20 names");
for(int i=0;i<20;i++)
{
names[i]=br.next();
}
for(int j=0;j<(20-1);j++)
{ for(int k=0;k<20-j-1;k++)
{
if(names[k].compareTo(names[k+1])<0)
{ String temp=names[k];
239
Question 9
Examiners’ comments:
Many candidates lost marks because of the absence of
menu and input choice, break and default statement. Suggestions for teachers
Some candidates did not follow the instruction and
wrote two separate programs. Additional practice on menu driven
programs.
(a) (i) Overlooked the instruction excluding number Teach all types of logical programs.
itself . Instruct candidates to read the
(ii) For finding the factor ‘/’ operator was used question carefully and follow the given
instead of % operator. instructions.
(b) (i) Variable for finding the factorial was
initialized with value 0 . Some candidates initialized the variable with value 1 but inside the
loop.
(iii) Loop to find the factorial was formed 1 to < n.
240
System.out.println("MENU");
System.out.println("1.FACTORS OF A NUMBER");
System.out.println("2.FACTORIAL OF A NUMBER");
System.out.println("ENTER A NUMBER");
int num=sc.nextInt();
System.out.println("ENTER YOUR CHOICE");
int choice=sc.nextInt();
switch (choice)
{
case 1:
System.out.print("FACTORS ARE=");
for(int i=1;i<=num/2;i++)
{
if(num%i==0)
System.out.print(i+",");
}
break;
case 2:
int f=1;
for(int i=1;i<=num;i++)
{
f=f*i;
}
System.out.println("FACTORIAL OF "+num+"="+f);
break;
default:
System.out.println("Wrong choice");
}
}}
241
242
September 2014
For further information and comments, please correspond with:
This document of the Analysis of Pupil Performance at the ICSE (Class-10) Examination is a unique tool for
retrospection for both, teachers and students. It has grown and evolved over the years to provide feedback to all
concerned in terms of the strengths and weaknesses of the candidates in handling the ICSE examinations.
We commend the work of Mr. Lancelot J Fuller, Deputy Secretary, and the ICSE Division of the Council who
have painstakingly prepared this analysis. We are grateful to the examiners who have contributed through their
comments on the performance of the candidates under examination as well as for their suggestions to teachers
and students for the effective transaction of the syllabus.
We hope the schools will find this document useful in more ways than one. We invite comments from schools
on further improving its utility and quality.
Gerry Arathoon
October 2014 Chief Executive & Secretary
The Council for the Indian School Certificate Examinations has published the “Analysis of Pupil Performance”
annually since 1994. This document is reviewed every year and changes are incorporated based on suggestions
received from various quarters which include experts in the field of education, Heads of Schools and teachers, in
order to make the analysis more useful and meaningful.
This document comprises both, a quantitative as well as a qualitative analysis of the performance of pupils at the
ICSE examinations. The Analysis of Pupil Performance has been carried out for the most studied subjects that
are largely ascribed to, by the schools. The purpose of this document is to give teachers and students a macro
view of the overall performance of all candidates who have taken the examination and examiners’ comments on
each question. It is hoped that this would enable teachers and students to understand the assessment of the ICSE
examinations better and help both, teachers and students, in the teaching – learning process, more effectively.
The qualitative analysis seeks to provide a transparent look at the assessment process in order to enhance the
effectiveness of the entire assessment procedure. Once the process of the evaluation of scripts is over, examiners
are requested to contribute detailed comments on the performance of candidates for each question. The
comments include the examiners’ response on what constitutes a good answer; common errors made by
candidates while answering the questions; the questions that appeal to students and the overall performance by
the students.
The quantitative analysis is based on the overall performance of all the students who took the examination. An
analysis of the percentage of students who obtained marks in different mark ranges is also included.
Mr. Richard Ellis, Mr. M.R. Felix, Mr. M. Gopal, Mr. C.M. Thomas, Mrs. Liza George and Mrs. Namita Bajaj
are to be commended for their meticulous and diligent effort in preparing this reference tool for both, teachers
and students.
Lancelot J Fuller
October 2014 Deputy Secretary
Mark Range
Details
0-20 21-40 41-60 61-80 81-100
Number of Candidates 2 73 6665 25943 56764
Percentage of Candidates 0.00 0.08 7.45 29.00 63.46
Cumulative Number 2 75 6740 32683 89447
Cumulative Percentage 0.00 0.08 7.54 36.54 100.00
70.00 63.46
Percentage of Candidates
60.00
50.00
40.00
29.00
30.00
20.00
7.45
10.00
0.00 0.08
0.00
0-20 21-40 41-60 61-80 81-100
Marks Obtained
226
ANALYSIS OF PERFORMANCE
Question 1
(b) What is meant by a package? Name any two Java Application Programming Interface
packages. [2]
(d) State one difference between the floating point literals float and double. [2]
(e) Find the errors in the given program segment and re-write the statements correctly to
assign values to an integer array.
int a = new int(5);
for(int i=0;i<=5;i++) a[i]=i; [2]
227
MARKING SCHEME
Question – 1
(a) (i)
(iii)
(b) A package is a group of related classes
Any two of the following:
java.applet java.sql javax.sound
java.awt java.text javax.swing
java.beans java.util javax.transaction
java.io javax.accessibility javax.xml
java.lang javax.crypto org.ietf
java.math javax.imageio org.omg
java.net javax.naming org.w3c
java.nio javax.net org.xml
java.rmi javax.print
java.security javax.rmi
(c) (i) long
(ii) char
228
Question 2
(a) Operators with higher precedence are evaluated before operators with relatively lower
precedence. Arrange the operators given below in order of higher precedence to lower
precedence.
(i) && (ii) % (iii) >= (iv) ++ [2]
(b) Identify the statements listed below as assignment, increment, method invocation or
object creation statements.
(i) System.out.println("Java");
(ii) costPrice = 457.50;
(iii) Car hybrid = new Car( );
(iv) petrolPrice++; [2]
(c) Give two differences between the switch statement and the if-else statement. [2]
(d) What is an infinite loop? Write an infinite loop statement. [2]
(e) What is a constructor? When is it invoked? [2]
229
MARKING SCHEME
Question - 2
(a) (iv), (ii), (iii), (i) All 4 correct
Only 1 incorrect
(b) (i) method invocation
(ii) assignment
(iii) object creation
(iv) increment All 4 correct
Only 1 incorrect
(c) switch:
can perform only equality (= =) comparison OR
can have a number of possible execution paths OR
works with the byte/short/char/int primitive data types OR
multiple branching OR
is used along with case statement OR default statement
If-else:
Can perform all relational comparisons (<, >, >=, <=, = =, !=) OR
executes a certain section of code only if a particular test evaluates to true OR
provides a secondary path of execution when an "if" clause evaluates to false OR
works with any data type OR conditional/control flow/decision statements
(d) A sequence of instructions which loops/iterates/repeats endlessly.
Any valid example which shows:
the loop having no terminating condition OR
230
(a) List the variables from those given below that are composite data types.
(i) static int x; (iv) boolean b;
(ii) arr[i]=10; (v) private char chr;
(iii) obj.display( ); (vi) String str; [2]
(b) State the output of the following program segment:
String str1= "great"; String str2= "minds";
System.out.println(str1.substring(0,2).concat(str2.substring(1)));
System.out.println(("WH"+(str1.substring(2).toUpperCase()))); [2]
(c) What are the final values stored in variables x and y below?
double a = − 6.35;
double b = 14.74;
double x = Math.abs(Math.ceil(a));
double y = Math.rint(Math.max(a,b)); [2]
(d) Rewrite the following program segment using if-else statements instead of the ternary
operator.
String grade=(mark>=90) ? "A" : (mark>=80) ? "B" : "C"; [2]
(e) Give the output of the following method:
public static void main(String[] args){
int a = 5;
a++;
System.out.println(a);
a−=(a−−) – (−−a);
System.out.println(a); } [2]
(f) What is the data type returned by the library functions:
231
232
233
MARKING SCHEME
Question - 3
(a) (ii) arr (iii) obj (vi) str All 3 correct
Any 2 correct
(b) grinds
WHEAT
( c) 6.0
15.0
(d) if(mark>=90) grade=”A”;
else if(mark>=80) grade=”B”;
else grade=”C”; All 3 correct
Any 2 correct
(e) 6
6−(6−4)=4
(f) (i) int
(ii) boolean
(g) 4
3756
(h) (i) 6 times
(ii) 0 to 9 OR {1,2,3,4,5,6,7,8,9}
(i) (i) a,b
(ii) x,y
(j) (i) x=1001
y=1001.0
(ii) The king said “Begin at the beginning!”to me.nextLine()
234
Write a main method to create an object of the class and call the above member methods. [15]
235
MARKING SCHEME
Question - 4
import java.io.*;//import java.util.*;
public class movieMagic
{
int year; float rating; String title;
public movieMagic()
{
year=0;
rating=0.0f;
title="";
}
do
{
System.out.println("Enter rating (minimum 0.0 and maximum 5.0)");
rating=Float.parseFloat(br.readLine()); // sc.nextInt();
}
while (!(rating>=0.0f && rating<=5.0.f)); OR while (rating < 0.0f rating
>5.0f );
}
object.accept();
object.display();
}
Step
Declaration of class and instance variables
Creating object of class BufferedReader/Scanner
Constructor properly declared and data members initialised
accept() method declaration (with exception handling if
required)
3 Inputs correct
Output title in display() method
Decision for rating<=2.0 and output
237
Question 5
A special two-digit number is such that when the sum of its digits is added to the product of its
digits, the result is equal to the original two-digit number.
Example: Consider the number 59.
Sum of digits = 5 + 9 = 14
Product of its digits = 5 × 9 = 45
Sum of the sum of digits and product of digits = 14 + 45 = 59
Write a program to accept a two-digit number. Add the sum of its digits to the product of its
digits. If the value is equal to the number input, output the message “Special 2-digit number”
otherwise, output the message “Not a special 2-digit number”. [15]
Examiners’ Comments:
Most candidates answered this question, but the Suggestions for teachers
- How to validate data should be taught
following errors were commonly observed:
with the help of examples.
(i) Checking for 2-digit number was missing.
- Extraction of digits logic n%=10 and
(ii) Extraction of digits using loop was not clear. n/=10 needs to be explained with
(iii) Candidates were confused in the use of numerous examples and exercises.
temporary variable for copying the original value - Why a copy of original value must be
in extraction of digits. maintained should be explained with a dry
run and which one to use where – if the
original is used in extraction loop then a
copy to be used in comparison or vice
versa.
238
Step
Input number
Initialise 2 sums and product
Store number in second variable
Check if number is 2-digit
condition for number >0 while(n>0)
Extract digit from number
Compute sum of digits
Compute product of digits
number/=10
Compute total of sum and product of digits
Check if total equals number
Output "Special Number" message
Output "Not Special Number" message
Description of variables/ comments/ mnemonics
239
digit1=Integer.parseInt(s1);
digit2=Integer.parseInt(s2);
sumDigit=digit1+digit2;
prodDigit=digit1*digit2;
sum=sumDigit+prodDigit;
if(sum==n)
System.out.println("Special Number");
else
System.out.println("Not a Special Number");
}
}
}
Step
Input number as String
Convert String to integer
Check if number is 2-digit
Extract first digit
Extract second digit
Convert first digit from String to integer
Convert second digit from String to integer
Compute sum of digits
Compute product of digits
Compute total of sum and product of digits
Check if total equals number
Output "Special Number" message
240
Question 6
Write a program to assign a full path and file name as given below. Using library functions, extract and
output the file path, file name and file extension separately as shown.
Input C:\Users\admin\Pictures\flower.jpg
Output Path: C:\Users\admin\Pictures\
File name: flower
Extension: jpg [15]
241
Step
Assign value to String (accept single slash instead of double slash)
Declare variables (ignore initialisation)
Find length of string
Loop
Extract character
Check if character is '.'
Extract substring for file extension
store position of '.'
Check if character is '//' (accept single slash instead of double slash)
Extract substring for file name
Extract substring for file path
break to exit loop
Output file path, file name, file extension
Description of variables/ comments/ mnemonics
OR
public class alternateSolution
{
public void sampleMethod()
{ String s="C:\\users\\admin\\pictures\\flower.jpg";
pos1=s.lastIndexOf('\\');
pos2=s.indexOf('.');
fpath=s.substring(0,pos1+1);
fname=s.substring(pos1+1, pos2);
242
System.out.println("Path: "+fpath);
System.out.println("Extension: "+fextn);
}
}
Step
Assign value to String (accept single slash instead of double slash)
Declare variables (ignore initialisation)
Find last index of slash (accept single slash instead of double slash)
Find index of '.'
Extract substring for file path
Extract substring for file name
Extract substring for file extension
Output file path
Output file name
Output file extension
Description of variables/ comments/ mnemonics
Question 7
Design a class to overload a function area( ) as follows:
(i) double area(double a, double b, double c) with three double arguments, returns the area
of a scalene triangle using the formula:
area = s ( s a)(s b)(s c)
abc
where s =
2
(ii) double area(int a, int b, int height) with three integer arguments, returns the area of a
trapezium using the formula:
1
area = height(a+b)
2
(iii) double area(double diagonal1, double diagonal2) with two double arguments, returns the
area of a rhombus using the formula:
243
MARKING SCHEME
Question - 7
public class overload
{
double area=0;
}
public double area(int a, int b, int height)
{
area=0.5*height*(a+b);
return area;
}
public double area(double diagonal1, double diagonal2)
{
double area=0.5*(diagonal1*diagonal2);
return area;
}
}
244
Question 8
Using the switch statement, write a menu driven program to calculate the maturity amount of
a Bank Deposit.
The user is given the following options:
(i) Term Deposit
(ii) Recurring Deposit
For option (i) accept principal(P), rate of interest(r) and time period in years(n). Calculate
n
r
and output the maturity amount(A) receivable using the formula A= P 1
100
For option (ii) accept Monthly Installment (P), rate of interest(r) and time period in months
(n). Calculate and output the maturity amount(A) receivable using the formula
n( n 1) r 1
A=P×n + P× × ×
2 100 12
For an incorrect option, an appropriate error message should be displayed. [15]
245
MARKING SCHEME
Question 8
import java.io.*; //import java.util.*;
public class bank
{ public void sampleMethod()throws IOException // throwsInputMismatchException
{ double P,A=0,r,n,x; int choice;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//Scanner sc=new Scanner(System.in);
System.out.println("Enter Choice(1) Term Deposit (2) Recurring Deposit ");
choice=Integer.parseInt(br.readLine());//sc.nextInt();
switch(choice)
{
case 1:
System.out.println(" Enter Principal:");
P=Double.parseDouble(br.readLine());//sc.nextDouble();
System.out.println(" Enter rate of interest:"); r=Double.parseDouble(br.readLine());
System.out.println(" Enter time period in years:");
n=Double.parseDouble(br.readLine());//sc.nextDouble();
x=1.0+r/100.0;
A=P*(Math.pow(x,n));
break;
case 2:
System.out.println(" Enter Monthly Instalment:");
P=Double.parseDouble(br.readLine());//sc.nextDouble();
System.out.println(" Enter rate of interest:"); r=Double.parseDouble(br.readLine());
System.out.println(" Enter time period in months:");
n=Double.parseDouble(br.readLine());//sc.nextDouble();
x=P*n;
A=x+ P*(n*(n+1)/2.0)*(r/100.0)*(1.0/12.0);
246
Step
Output menu
Input option
switch statement
case 1 and break
Input 3 parameters (any data type)
Compute Amount for term deposit (ignore data types)
case 2 and break
Input 3 parameters (any data type)
Computing Amount for recurring deposit (ignore data types)
default statement with appropriate message
Output Amount (ignore formatting)
Description of variables/ comments/ mnemonics
Question 9
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”.
{1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010} [15]
247
MARKING SCHEME
Question 9
import java.io.*; //import java.util.*;
public class BinarySearch {
public static void main() throws IOException
{ int[] intArray = {1982, 1987, 1993, 1996, 1999, 2003, 2006, 2007, 2009, 2010};
int searchValue = 0;
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//Scanner sc=new Scanner(System.in);
System.out.print("Enter a number to search for: ");
searchValue = Integer.parseInt(br.readLine());//sc.nextInt();
boolean b=false;
int start, end, mid;
start = 0;
end = intArray.length - 1; // end=9
while (start <= end) {
mid = (start + end) / 2;
if (intArray[mid] == searchValue)
1 mark
{ System.out.println("Record exists"); b=true; break;}
else if (intArray[mid] < searchValue)
start = mid + 1;
248
end = mid - 1;
}
if (b==false) System.out.println("Record does not exist");
}
}
Step
Assign (or accept) values to integer array
Input number to be searched
249
Computer Applications is a logic based subject like Mathematics and highly scoring in nature. It
needs to be given time of self-study revision and practice at least 3 times a week for a duration of ½
an hour each day followed by a complete review of week’s work during the week end. Do not leave
this subject to be studied on the eve of the examination.
All exercises, general and Programming to be maintained in a register and revised during exam
preparation.
Syntax of each element of Java to be thoroughly studied.
At the time of answering, every question must be read at least twice before answering.
All programs must be written with suitable comments – whether in class or during exam.
A good variable description containing a list of important variables used in the program along with
their data types and purpose must be given at the end of every program.
250