0% found this document useful (0 votes)
12 views6 pages

Java Output

The document contains a series of Java programming exercises with their corresponding outputs. Each question involves different programming concepts such as loops, conditionals, and string manipulation. The answers provided demonstrate the expected output for each code snippet.

Uploaded by

7emehak
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)
12 views6 pages

Java Output

The document contains a series of Java programming exercises with their corresponding outputs. Each question involves different programming concepts such as loops, conditionals, and string manipulation. The answers provided demonstrate the expected output for each code snippet.

Uploaded by

7emehak
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

ICSE COMPUTER APPLICATION

BLUEJ OUTPUT

Q1
class out1
{
public void main(){
int a=0;int i=4;
while(i<10)
{
a=i*2;i++;
System.out.print(i);
System.out.println(a);
}}}

Ans:
58
610
712
814
916
1018

Q2
class out2
{
public void main(){
for(int i=12;i>5;i=i-2)
{
System.out.println();
System.out.println(i++);
}}}
Ans:
12
11
10
9
8
7
6

Q3.
for(int m=5;m<=20;m=m+5)
{
if(m%3==0)
break;
else
if(m%5==0)
System.out.println(m);
continue;
}
Ans:
5
10

Q4
int p=200;
while(true)
{
if(p<100)
break;
p=p-20;
}
System.out.println(p);
Ans: 80

Q5
int s=0,i=0;
while(i++<10)
{
s+=i;
i++;
System.out.println(s);}
Ans:
1
4
9
16
25
Q6.
String s="Object";
int l=s.length();
for(int c=0;c<l;c++)
{
if(Character.isLowerCase(s.charAt(c)))
System.out.print(Character.toUpperCase(s.charAt(c)));
else if(c%22==0)
System.out.print('E');
else
System.out.print(Character.toLowerCase(s.charAt(c)));
}
Ans: EBJECT

Q7.
for(int i=1;i<=5;i++)
{
for(int j=1;j<=i;j++)
{
if((i+j)%2==0)
System.out.print(1);
else
System.out.print(0);
}
System.out.println();
}
Ans:
1
01
101
0101
10101

Q8.
int i=60;
while(true)
{
if(i<=12)
break;
i=i-12;
}
System.out.println("i="+i);
Ans: i=12
Q9.
int a=5; int m=0;
while(a<=7)
{
a++;
System.out.print("a="+a);
m+=a;
System.out.println("m="+m);}
Ans:
a=6m=6
a=7m=13
a=8m=21

Q10.

for(int a=3;a>=-1;a--)
{
for(int b=-5;b>-8;b--)
System.out.print("#");
System.out.println();
}
Ans:
###
###
###
###
###

Q11.

int x=5243;
while(x>0)
{
x=x/10;
System.out.println(x);
}
Ans:
524
52
5
0

Q12.
int x=29;
while(x>0)
{
x/=10;
System.out.println(x);
}
Ans:
2
0
Q13.
for(int x=-5;x<=-1;x++)
System.out.println(x++);
Ans:
-5
-3
-1
Q14.
for(int i=2;i<20;i=i+2)
{
if(i<10)
continue;
else
{
System.out.print(i);
break;
}}
Ans:
10
Q15.
int p=4, q = 36;
while(p<=q)
{
q=q/p;
System.out.println(q);
}
Ans:
9
2

You might also like