 This paper is divided into two sections. You are to answer all the questions from section A, and any four from section B.
Section A

(40 marks)
Q 1. [5X2=10]

2. Differentiate entry controlled loop and Exit controlled loop.
3. Define abstraction with example.
4. Write two features of a constructor.
5. Write the output of the following.
int y=6;
do
{ System.out.print(y++ +”.”);
y++;
}while(y<=12);

Q 2. [5X2=10]

1. What is fallthrough. Explain with an example.
2. Convert the following code to if …else.
P=(g==9.8)?0:1
3. Write the output of the following.
int k=66, f=2,g=6,rank=1;
if(k%f!=0 || k%g!=0)
{
rank =0;
}
System.out.println(“Rank=”+ rank);
4. Convert the following code to do……while loop.
Int Q=7, K=10;
While (Q>2)
{
K+=2;
Q–;
}
System.out.println(“Result=”+K);
5. What will be the value of k after the execution of the following code?
int a=20,k=15;
k=k+ a++ + ++a/2;

Q 3. [10X2=20]

1. Differentiate between pure and impure function.
2. Write an expression in java for ax4+by3+c
3. String str=”ICSE Examination 2020″;
System.out.println(Integer.valueOf(str.substring(str.length()-3))+ str.length());
System.out.println(str.substring(0,4)+str.lastIndexOf(“a”));
4. String str=”snv school”;
Char c1=Character.toUpperCase(str.charAt(0));
Char c2= Character.toUpperCase(str.charAt(str.lastIndexOf(“ “)+1));
System.out.println(c1+ “.” +c2);
5. Write the output of the following.
System.out.println((x+y>x*3)?x++:y); (Assume x=15, y=5)
6. What would be returned by Math.ceil(3.78) and Math.abs(Math.rint(-51.2))
7. What is the purpose of the new operator?
8. Given the String array as
String ar[]={“English”, “Physics”, “Geography”,”Maths”, “Computers”};
Write the output of the following.
System.out.println((ar.substring(0,5)).concat(ar.substring(2)));
System.out.println(ar.endsWith(“s”));
9. Write any two differences in Implicit Type Casting and Explicit Type Casting.
10. What is difference between single dimensional array and multidimensional array?

Section B
Attempt any four programs. [4X15=60]
Q 4. Write a program to accept a string. Convert the strings to uppercase and output the number of Consecutive letter pairs that exist in the string
Sample Input: IT WAS NOT TOUGH FOR HIM TO RESIDE ABOVE THE HILL
Output: Number of Consecutive pair of characters: 6 

Q 5. Write a program to overload a function print() as follows. 
a. void print(int a , int b ): To print the odd numbers between a and b
b. void print(char a , char b):To print all the consonants between a and b
c. void print(char ch, int n):To make the following patterns using the character stored in ch and the number stored in n.
Input: ch= @ and n=3
Output: @
@@
@@@
Q 6.
Define a class taximeter having the following description:
Data members/instance variables:
Int taxino – to store taxi number
String name – to store passenger’s name
int km – to store number of kilometres travelled
Member functions:
taximeter () — constructor to initialize taxino to 0, name to “ ”and b to 0.
input () – to store taxino,name,km
calculate() – to calculate bill for a customer according to given conditions
kilometers travelled(km) Rate/km
1 km Rs 20
1 < km 6 Rs 6
6 km 12 Rs 12
12 km 18 Rs 14
18 km Rs 17
display()- To display the details in the following format
Taxino Name Kilometres travelled Bill amount
– – – –
Create an object in the main method and call all the above methods in it. 
Q 7. Write a program to input a double dimensional array and print the sum of each row. The size of the array will be given by the user.
For Example: If the array is :
2 3 5
4 7 1
9 8 6
Output:
The sum of the row 1: 10
The sum of the row 2: 12
The sum of the row 3: 23 
Q 8 A cloth showroom has announced the following festival discounts on the purchase of
items, based on the total cost of the items purchased.
Totalcost Discount
LessthanRs.2000 5%
Rs.2001toRs.5000 25%
Rs.5001toRs.10000
AboveRs.10000 35%
50%

500/o

Write a program to input the total cost and to compute and display the amount to be paid by the customer after availing the discount. 
Q 9. Design a menu driven program, that accepts an integer and displays the following menu :
i. Displays the sum of the digits of the numbers.
Example : 12
The sum of digits is: 3 
ii. A number that is smaller than the sum of its factors excluding the highest factor is said to be an abundant number.
Example number: 12
Sum of its factors excluding the highest factor: 1+2+3+4+6=16
Write a program to print all abundant numbers in the range 1 to n (both inclusive), where n is to be accepted in the program. Print the output with the appropriate message. 

SHARE
Previous articleElectricity Bill program
Next articleICSE practical sample paper 3