Icse 9
Icse 9
Q7 (i) State the number of bytes occupied by char and int data types?
(ii) Write one difference between / and % operator.
Q8 Give the output of the following program segment and also mention the number 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);
TANAYA CHATTERJEE
TC Tutorial
Hakim Para, Siliguri
Q9 What is the value of y after evaluating the expression given below?
y += ++y + y– + –y; when int y = 8.
Q10 The following program is supposed to check the given number is prime or not. Some part of the
program is replaced by ______, with the numbering 1 to 5, fill this part so that program works
correctly.
class checkPrime {
public static void main(String args[]) {
int i, f=0;
int n = Integer.parseInt(args[0]);
for(i=__1__; __2__; i++)
{
if(__3__==0)
{
f=__4__;
break;
}
}
if(f==__5__)
System.out.print(“The given no. “+n+” is a prime number”);
else
System.out.print(“The given no. “+n+” is not a prime number”);
}
}
Q11 Give the output and show the dry run.
public static void abc()
{
int x=1, i=2;
do
{
x*=i;
}while(++i<=5);
System.out.println(x);
}
Q12 What is the output of the following?
char c = ‘A’;
short m = 26;
int n = c + m;
System.out.println(n);
Q13 Analyse the given program segment and answer the following questions:
for(i = 3; i <=4; i++)
{
for(j=2; j<i; j++)
{
System.out.print(""),
}
System. out. println ("WIN");
}
How many times does the inner loop will execute?
Write the output of the program segment.
TANAYA CHATTERJEE
TC Tutorial
Hakim Para, Siliguri
Q14 Give the output of the following program.
int i,j;
for (i=0; i<4; i++)
{
for (j=i; j>=0; j--)
System.out.print(j);
System.out.println();
}
Q15 What will be the output of the following code?
int m=2
int n=15;
for(int i=1;i<5;i++)
m++; - - n;
System.out.println("m="+m);
System.out.println("n="+n);
Q16 What do you mean by type conversion? How is implicit conversion different from explicit
conversion?
Q17 What is difference between ASCII and Unicode. Which one does Java uses? What are ASCII
codes for small letters?
Q18 Why is Java called as Platform Independent Language?
Q19 What is difference between Local, Instance, Global and Class Variables?
Q20 What is the difference between if and switch?
SECTION B (60 MARKS)
Attempt any 4 programs
Q1 A library charges fine for books returned late.
Following are the fines:
first five days 40 paisa per day
Six to ten days 65 paisa per day
above 10 days 80 paisa per day.
Design a program to calculate the fine assuming that a book is returned N days late.
Volume of a cuboid: (v = l × b × h)
Volume of a cylinder: (v = π× r²× h)
Volume of a cone: (v = 1/3× π × r²× h) (π = 22/7)
Using a switch case statement, write a program to find the volume of different solids by taking
suitable variables and data types.
TANAYA CHATTERJEE
TC Tutorial
Hakim Para, Siliguri
Q6. 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 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, then display the message “Special 2 – digit number”
otherwise, display the message “Not a special two-digit number”.
7. input a number and verify whether it is a Lead Number or not. A number is called a Lead number
if the sum of the even digits is equal to the sum of the odd digits. For example, 1452. [15]
8. Write a program to print the given series: [15]
3 6 12 24 48 96 …. up to n terms
TANAYA CHATTERJEE