8/30/25, 5:11 PM Test Generator
Roll No : School : Time :
Date : Assessment :
Marks: 28
Subject :
Class :
1 What is the output? 1
int i = 1, j = 2;
for(; i < 3 && j > 0 ; i++ , j--);
{
[Link](i + ″ ″ + j + ″ ″);
}
(a) 1 2, 2 1,
(b) 2 1, 1 2,
(c) 1 2, 2 1, 3 0,
(d) Error/None of the above
2 What is the output? 1
int b = 3;
while (b--) {
[Link](b + ″,″);
}
(a) 1,2,3 (b) 3,2,1
(c) 2,1,0 (d) None of the above
3 Write the output: 1
a=1; b=2;
while(a<3 && b-1>0) {
[Link](b+ ″ ″);
a++ ;
}
(a) 1 1 (b) 2 2
(c) 1 2 (d) None of the above`
4 (a) What will be the output of the following code ? 3
(i) int m=2;
int n=15;
for(int i = 1; i<5;i++);
m++; --n;
[Link] 1/4
8/30/25, 5:11 PM Test Generator
[Link](″m=″+m);
[Link](″n=″+n);
(ii) char x=‘A’; int m;
m=(x==‘a’)? 'A' : 'a';
[Link](″m=″+m);
(b) Analyse the following program segment and determine how
many times the loop will be executed and what will be the output of the
program segment.
int k=1, i=2;
while(++i<6)
k*=i;
[Link](k);[2010]
5 Write the output of the following program code: [2015] 3
char ch;
int x=97;
do
{
ch= (char) x;
[Link](ch + ″ ″);
if( x%10==0)
break;
++x;
}while(x<= 100);
6 How many times will the following loop execute? What value will be 3
returned?[2013]
int x=2, y=50;
do {
++x;
y–=x++;
} while(x<=10);
return y;
7 Analyze the given program segment and answer the following questions: 3
[2016]
(a) Write the output of the program segment.
(b) How many times does the body of the loop gets executed?
for (int m=5; m<=20; m+=5)
{ if (m%3==0)
[Link] 2/4
8/30/25, 5:11 PM Test Generator
break;
else
if(m%5==0)
[Link](m);
continue;
}
8 Write a program to accept a number and check if it is an automorphic number 3
or not. (Use switch-case statement)
Hint: Automorphic number : An automorphic number is the number which is
contained in the last digit(s) of its square.
Example 25 is an automorphic number as its square is 625 and 25 is present as
the last two digits.
9 State the output of the following java program statements: 3
(a) public class QuesQ10a
{
public static void main()
{
for(int i=0;i<10;i = i + 2)
{[Link](++i);}
}
}
(b) public class Ques10b
{
public static void main()
{
for(int i=12;i>5;i=i-2)
{
[Link]();
[Link](i);
}
}
}
(c) int i,sum;
for(i=5,sum=1;sum<10;i++) {
sum+=i;}
[Link](″sum is= ″+sum);
(d) int a=0,i=4;
while(i<10) {
[Link] 3/4
8/30/25, 5:11 PM Test Generator
a=++i-i*2;
}
[Link](″a= ″ + a + ″i= ″ + i);
10 Write a program to calculate and print the sum of each of the following series 3
:
(a) Sum (S) = 2 – 4 + 6 – 8 + ............. – 20
(b) Sum (S) =
(Value of x to be input by the user.)
11Write a program to input a number and print whether the number is a special 4
number or not.
(A number is said to be a special number, if the sum of the factorial of the digits
of the number is same as the original number).
Example: 145 is a special number, because 1!+4!+5! = 1+24+120 = 145
(Where ! stands for factorial of the number and the factorial value of a number
is the product of all integers from 1 to that number, example 5! = 1*2*3*4*5 =
120).
[Link] 4/4