2
Most read
3
Most read
4
Most read
Find OUTPUT of The following Code
1 int i,k;
for(i=1,k=1;i<=5;k+=i,i++)
System.out.println(i+" "+k);
2 int x=5,y;
y=++x;
System.out.println(y);
3 int a = 25;
System.out.println(a++);
System.out.println(--a);
4 int x = 5, y=6, z;
z = x++ + ++y;
System.out.println(z);
5 int m=12;
int n = m++ * 5 + --m
System.out.println(n);
6 int y=14;
int z = (++y * (y++ + 5))
7 int x = 20, y = 5, z;
z = x > y ? 100 : 50;
System.out.println(z);
8 int x =25, y;
y = ++x % 6;
System.out.println(y);
9 int a = 10, b = 5, p;
p = a++ + ++b;
System.out.println(p+” “+a+” “+b);
10 for(int x = 1; x<=15; x+=2)
System.out.println(x);
11 int x = 5;
while(x>10)
{
System.out.println(x);
x++;
}
12 int a = 5;
do
{
System.out.println(a);
a++;
}while(a<4);
13 int k=5,j=9;
k+= k++ - ++j + k;
System.out.println(“k=”+k);
System.out.println(“j=”+j);
14 double b = -15.6;
double a = Math.rint(Math.abs(b));
System.out.println(“a=”+a);
15 State the number of times loop will be
executed and the final output :
int p = 200;
While(true)
{
if(p<100)
break;
p=p-20;
}
System.out.println(p);
16 int x = 1, y = 5;
while (x<y)
{
y++;
x+=2;
}
System.out.println(x+” “+y);
17 for(int x = 1; x<=20; x++)
{
if(x % 5 == 0)
continue;
System.out.println(x);
}
18 for(int x = 1; x<=20; x++)
{
if(x % 7 == 0)
break;
System.out.println(x);
}
19 int a = 25, b = 39;
while(b>0)
{
b = b – a;
a = a – b;
}
System.out.println(a + “ “+b);
20 for(int x=0;x<=15;x+=2);
System.out.println(x);
21 int a = 5, b = 7, c;
c = ++a + b++ + --a;
System.out.println(c);
22 int x = 20, y = 25;
x = ++x + y++ + --y + --x;
System.out.println(x);
23 int n = 2,m;
m = --n *2*n;
System.out.println(m);
24 int a = 25;
int b = (++a * 4) % 25;
System.out.println(b);
25 char c = ‘A’;
short m = 26;
int n = c + m;
System.out.println(n);
26 What will be the value of following expression
if the value of m = 5 and n=20?
(m + n) > 25 ? 200 : 20;
27 Int x = 99, y = 10;
y = ++x;
System.out.println(“X:”+x+” Y:”+y);
28 double x = 0.055,y = 100.05;
System.out.println((int)(x*y));
29 int x = 10, y=15;
x = x+y;
y = x-y;
x = x-y;
System.out.println(x+ “ *** ”+y);
30 int sum = 20;
if(sum<20)
System.out.print(“Under ”);
else
System.out.println(“Over “);
System.out.println(“the limit”);
31 What will be the output, if n = 1 and if n= 2 in
the following code?
switch(n)
{
case 1:
System.out.println(“One);
break;
case 2:
System.out.println(“ Zero”);
default:
System.out.println(“Wrong input”);
}
32 int s=1,p=0;
for(int j = 1;j<=8;j++)
{
if(j<=4)
s*=j;
else
p+=j;
}
System.out.println(s+” “+p);
33 If array[]={1,9,8,5,2};
i) What is array.length?
ii) What is array[2]?
34 int x[]={1,2,3,4,5}, y ={5,4,3,2,1};
int i,j;
for(i=0,j=x.length;i<x.length;i++,j- -)
System.out.println(x[i] * y[j]);
35 String s = “Please come, let us go to play”;
System.out.println (s.substring(7,11));
System.out.println (s.lastIndexOf(‘o’));
System.out.println (s.toUpperCase());
System.out.println (s.charAt(17));
System.out.println (s.indexOf(9,’o’));
System.out.println (s.substring(0,6) +
s.substring(20,22));
36 Sting k=”WELCOME TOPPERS”
System.out.println(k.toLowerCase());
System.out.println(k.length());
System.out.println(k.indexOf(‘E’));
System.out.println(k.replace(‘O’,’A’));
System.out.println(k.substring(8));
37 String n = “Computer Knowledge.”;
String m = “Computer Application”;
System.out.println
(n.substring(0,8).concat (m.substring(9)));
System.out.println(n.endsWith(“e”);
38 System.out.println(“Four:”+(4+2));
System.out.println(“Four:”+2+2);
39 State the output of the following code
fragment, where int choice =1, x= 0;
y = 0, z=0;
switch(choice++)
{
case 2: x++; y--; z++;
break;
case 3: x+=2; y+=3; z-=3;
default: ++x; ++y; ++z;
}
System.out.println(“X=”+x+”Y =”+y+”Z=”+z);
Questions to practice to find LOGICAL and SYNTAX error in the code
1. public int getData(int num1, int num2)
{
int result = num1 + num2;
System.out.println(“Result is :” +
result);
}
2. class Add
{
public void doAddition(int x, y)
{
System.out.print(x+y);
}
}
3. if(x = 1)
k=100;
else
k = 10;
4. if ( x > y)
System.out. println(“y is greater”);
else
System.out. println(“x is greater”);
5. int i=5, j = 10
if ( (i < j) || (i=10))
System.out.println(“OK”);
System.out.println(“not OK);
6. int x=0;
while(x < 10)
System.out.println(x);
x ++;
7. for ( x = 0; x>= 10; x- -)
System.out.println(x);
8. for (i = 0, i <= 25; i ++)
System.out.println(i);
System.out.println(“the value is “;x);
9. public int add(int x,int y)
{
int z=x + y;
}
10. int a = 5 , b = 7 , c = 1;
if (a > b || b > c)
System.out.println(a + “ is greater”);
11. int a =90, b = 45, c = 45
if(a = = 90 && b = = 90 && c = = 90)
System.out.println(“Right angle
Triangle”);
12. double p =1000.00, t = 5.0, r = 10.5;
I = p * r * t / 100;
System.out.println(I);
13. double average = M1+M2+M3+M4 / 4;
14. String s = ‘computer’;
15. int l = “Good Morning”.length;
16. for (int x = 1; x < = 10 ; x++)
{
n = 1;
System.out.println(n);
n++;
}
correct the code to get 1 3 5 7 9 11 13
15 17 19 output.
17. int x, y, z;
x = 6;
y = 7;
x + y = z;
System.out.println(z);
18. int a[] = new int [10];
for( x =1 ; x<=15 ; x++)
a[x] = x * x;
19. int n = integer.ParseInt(br.readline());
20. String st = “School”;
System.out.println(st.reverse( ));
21. int x = 5, y = 8, temp;
temp = x;
x = y;
y = temp;
System.out.println(x, y, temp);
22. int x[ ] = [3,6,8,4,7,0,4,1,5];
23. int ar[ ] = [3,6,8,4,7,0,4,1,5];
System.out.println(ar.length());
Express the following in Java expression
(1-y3
)0.5
√ (x2 – x1)2
+ (y2 - y1)2
–b + (b2
-4ac)/2a
3x2
+2y [2011]
x - y
(x2
- 2y2
)3
(1 + x4
)0.25
a = (0.05 – 2y3
)/x - y
A3
+ B3
+ C3
– 3ABC
x1/3
√ l2
+ b2
x – [ y – {+ (a + b – c – d)}]
3x2
y+2yx2
( x – y)0.5
s = ut + ½at2
(a + b)n
√3 + b
√ 2as + u2
(2012)
5x * 7 – 5x
5x+2
– 5x+1
2AB + 2BC + 2CA
X2Y2 + Y2Z2 + Z2 + X2
Find the output of the following code (Java for ICSE)

More Related Content

PDF
ICSE Mathematics Formulae Sheet
PDF
Physics formula ICSE_Standard 10
DOCX
List of programs to practice for ICSE
PDF
Physics Derivations Class XI NCERT All Chapters and Important Questions
PDF
ICSE CLASS 10 | TOP 30 MOST IMPORTANT MCQ QUESTIONS | COMPUTER APPLICATIONS |
PDF
ICSE 10 History & Civics Concept Maps Preview.pdf
PDF
Class X geography question bank
PDF
Chemistry equations for ICSE Class 10
ICSE Mathematics Formulae Sheet
Physics formula ICSE_Standard 10
List of programs to practice for ICSE
Physics Derivations Class XI NCERT All Chapters and Important Questions
ICSE CLASS 10 | TOP 30 MOST IMPORTANT MCQ QUESTIONS | COMPUTER APPLICATIONS |
ICSE 10 History & Civics Concept Maps Preview.pdf
Class X geography question bank
Chemistry equations for ICSE Class 10

What's hot (20)

PPT
Flow of Control
PPT
Number System
PDF
VTU Data Structures Lab Manual
PPTX
Chapter 02 functions -class xii
PPTX
Computer System Overview Class XI CS
PPTX
computer Quiz image puzzle(IT QUIZ)
PPTX
Chapter 16 Dictionaries
PPSX
INTRODUCTION TO C PROGRAMMING
PPTX
Chapter 15 Lists
PDF
Poster Making - Grade 11 English CBSE
PDF
Data representation notes class 11
PPTX
Statistics Math project class 10th
PDF
Data Structures Practical File
PPTX
Chapter 14 strings
PPTX
Conditional and control statement
PPTX
Presentation on C++ Programming Language
PPTX
Chapter 08 data file handling
PDF
Object oriented programming c++
PPTX
C++ Overview PPT
PPTX
Asymptotic notations
Flow of Control
Number System
VTU Data Structures Lab Manual
Chapter 02 functions -class xii
Computer System Overview Class XI CS
computer Quiz image puzzle(IT QUIZ)
Chapter 16 Dictionaries
INTRODUCTION TO C PROGRAMMING
Chapter 15 Lists
Poster Making - Grade 11 English CBSE
Data representation notes class 11
Statistics Math project class 10th
Data Structures Practical File
Chapter 14 strings
Conditional and control statement
Presentation on C++ Programming Language
Chapter 08 data file handling
Object oriented programming c++
C++ Overview PPT
Asymptotic notations
Ad

Similar to Find the output of the following code (Java for ICSE) (20)

DOCX
703497334-ICSE-Class-9-Computer-Applications-Sample-Question-Papers.docx
DOCX
Java Practical1 based on Basic assignment
PDF
Simple Java Program for beginner with easy method.pdf
PDF
Java_Programming_by_Example_6th_Edition.pdf
PPTX
Iteration- series part 1- computer ICSE.pptx
PPTX
Iteration- series ICSE computer part 1.pptx
PDF
Simple 27 Java Program on basic java syntax
PPT
Algorithms with-java-1.0
PPTX
Presentation1 computer shaan
PDF
Sam wd programs
PDF
Review Questions for Exam 10182016 1. public class .pdf
PPTX
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
PDF
81818088 isc-class-xii-computer-science-project-java-programs
DOCX
ExamName___________________________________MULTIPLE CH.docx
DOCX
Example of JAVA Program
PDF
Which if statement below tests if letter holds R (letter is a char .pdf
DOC
Java final lab
DOCX
100 Small programs
PDF
&Y tgs P kii for
PPT
ch05-program-logic-indefinite-loops.ppt
703497334-ICSE-Class-9-Computer-Applications-Sample-Question-Papers.docx
Java Practical1 based on Basic assignment
Simple Java Program for beginner with easy method.pdf
Java_Programming_by_Example_6th_Edition.pdf
Iteration- series part 1- computer ICSE.pptx
Iteration- series ICSE computer part 1.pptx
Simple 27 Java Program on basic java syntax
Algorithms with-java-1.0
Presentation1 computer shaan
Sam wd programs
Review Questions for Exam 10182016 1. public class .pdf
WINSEM2020-21_STS3105_SS_VL2020210500169_Reference_Material_I_01-Mar-2021_L12...
81818088 isc-class-xii-computer-science-project-java-programs
ExamName___________________________________MULTIPLE CH.docx
Example of JAVA Program
Which if statement below tests if letter holds R (letter is a char .pdf
Java final lab
100 Small programs
&Y tgs P kii for
ch05-program-logic-indefinite-loops.ppt
Ad

Recently uploaded (20)

PPTX
Chapter 1 - Transaction Processing and Mgt.pptx
PPTX
Comprehensive Guide to Digital Image Processing Concepts and Applications
PDF
Top 10 Project Management Software for Small Teams in 2025.pdf
PPTX
Folder Lock 10.1.9 Crack With Serial Key
PDF
Engineering Document Management System (EDMS)
PPTX
ESDS_SAP Application Cloud Offerings.pptx
PDF
Ragic Data Security Overview: Certifications, Compliance, and Network Safegua...
PDF
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
PDF
Crypto Loss And Recovery Guide By Expert Recovery Agency.
PPTX
FLIGHT TICKET API | API INTEGRATION PLATFORM
PPTX
MCP empowers AI Agents from Zero to Production
PDF
What Makes a Great Data Visualization Consulting Service.pdf
PPTX
Chapter_05_System Modeling for software engineering
PDF
IT Consulting Services to Secure Future Growth
PDF
solman-7.0-ehp1-sp21-incident-management
PDF
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
PPTX
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
PPTX
UNIT II: Software design, software .pptx
PPT
3.Software Design for software engineering
PPTX
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...
Chapter 1 - Transaction Processing and Mgt.pptx
Comprehensive Guide to Digital Image Processing Concepts and Applications
Top 10 Project Management Software for Small Teams in 2025.pdf
Folder Lock 10.1.9 Crack With Serial Key
Engineering Document Management System (EDMS)
ESDS_SAP Application Cloud Offerings.pptx
Ragic Data Security Overview: Certifications, Compliance, and Network Safegua...
SOFTWARE ENGINEERING Software Engineering (3rd Edition) by K.K. Aggarwal & Yo...
Crypto Loss And Recovery Guide By Expert Recovery Agency.
FLIGHT TICKET API | API INTEGRATION PLATFORM
MCP empowers AI Agents from Zero to Production
What Makes a Great Data Visualization Consulting Service.pdf
Chapter_05_System Modeling for software engineering
IT Consulting Services to Secure Future Growth
solman-7.0-ehp1-sp21-incident-management
Coding with GPT-5- What’s New in GPT 5 That Benefits Developers.pdf
DevOpsDays Halifax 2025 - Building 10x Organizations Using Modern Productivit...
UNIT II: Software design, software .pptx
3.Software Design for software engineering
Streamlining Project Management in the AV Industry with D-Tools for Zoho CRM ...

Find the output of the following code (Java for ICSE)

  • 1. Find OUTPUT of The following Code 1 int i,k; for(i=1,k=1;i<=5;k+=i,i++) System.out.println(i+" "+k); 2 int x=5,y; y=++x; System.out.println(y); 3 int a = 25; System.out.println(a++); System.out.println(--a); 4 int x = 5, y=6, z; z = x++ + ++y; System.out.println(z); 5 int m=12; int n = m++ * 5 + --m System.out.println(n); 6 int y=14; int z = (++y * (y++ + 5)) 7 int x = 20, y = 5, z; z = x > y ? 100 : 50; System.out.println(z); 8 int x =25, y; y = ++x % 6; System.out.println(y); 9 int a = 10, b = 5, p; p = a++ + ++b; System.out.println(p+” “+a+” “+b); 10 for(int x = 1; x<=15; x+=2) System.out.println(x); 11 int x = 5; while(x>10) { System.out.println(x); x++; } 12 int a = 5; do { System.out.println(a); a++; }while(a<4); 13 int k=5,j=9; k+= k++ - ++j + k; System.out.println(“k=”+k); System.out.println(“j=”+j); 14 double b = -15.6; double a = Math.rint(Math.abs(b)); System.out.println(“a=”+a); 15 State the number of times loop will be executed and the final output : int p = 200; While(true) { if(p<100) break; p=p-20; } System.out.println(p); 16 int x = 1, y = 5; while (x<y) { y++; x+=2; } System.out.println(x+” “+y); 17 for(int x = 1; x<=20; x++) { if(x % 5 == 0) continue; System.out.println(x); } 18 for(int x = 1; x<=20; x++) { if(x % 7 == 0) break; System.out.println(x); } 19 int a = 25, b = 39; while(b>0) { b = b – a; a = a – b; } System.out.println(a + “ “+b); 20 for(int x=0;x<=15;x+=2); System.out.println(x); 21 int a = 5, b = 7, c; c = ++a + b++ + --a; System.out.println(c); 22 int x = 20, y = 25; x = ++x + y++ + --y + --x; System.out.println(x); 23 int n = 2,m; m = --n *2*n; System.out.println(m); 24 int a = 25; int b = (++a * 4) % 25; System.out.println(b); 25 char c = ‘A’; short m = 26; int n = c + m; System.out.println(n); 26 What will be the value of following expression if the value of m = 5 and n=20? (m + n) > 25 ? 200 : 20;
  • 2. 27 Int x = 99, y = 10; y = ++x; System.out.println(“X:”+x+” Y:”+y); 28 double x = 0.055,y = 100.05; System.out.println((int)(x*y)); 29 int x = 10, y=15; x = x+y; y = x-y; x = x-y; System.out.println(x+ “ *** ”+y); 30 int sum = 20; if(sum<20) System.out.print(“Under ”); else System.out.println(“Over “); System.out.println(“the limit”); 31 What will be the output, if n = 1 and if n= 2 in the following code? switch(n) { case 1: System.out.println(“One); break; case 2: System.out.println(“ Zero”); default: System.out.println(“Wrong input”); } 32 int s=1,p=0; for(int j = 1;j<=8;j++) { if(j<=4) s*=j; else p+=j; } System.out.println(s+” “+p); 33 If array[]={1,9,8,5,2}; i) What is array.length? ii) What is array[2]? 34 int x[]={1,2,3,4,5}, y ={5,4,3,2,1}; int i,j; for(i=0,j=x.length;i<x.length;i++,j- -) System.out.println(x[i] * y[j]); 35 String s = “Please come, let us go to play”; System.out.println (s.substring(7,11)); System.out.println (s.lastIndexOf(‘o’)); System.out.println (s.toUpperCase()); System.out.println (s.charAt(17)); System.out.println (s.indexOf(9,’o’)); System.out.println (s.substring(0,6) + s.substring(20,22)); 36 Sting k=”WELCOME TOPPERS” System.out.println(k.toLowerCase()); System.out.println(k.length()); System.out.println(k.indexOf(‘E’)); System.out.println(k.replace(‘O’,’A’)); System.out.println(k.substring(8)); 37 String n = “Computer Knowledge.”; String m = “Computer Application”; System.out.println (n.substring(0,8).concat (m.substring(9))); System.out.println(n.endsWith(“e”); 38 System.out.println(“Four:”+(4+2)); System.out.println(“Four:”+2+2); 39 State the output of the following code fragment, where int choice =1, x= 0; y = 0, z=0; switch(choice++) { case 2: x++; y--; z++; break; case 3: x+=2; y+=3; z-=3; default: ++x; ++y; ++z; } System.out.println(“X=”+x+”Y =”+y+”Z=”+z); Questions to practice to find LOGICAL and SYNTAX error in the code 1. public int getData(int num1, int num2) { int result = num1 + num2; System.out.println(“Result is :” + result); } 2. class Add { public void doAddition(int x, y) { System.out.print(x+y); } } 3. if(x = 1) k=100; else k = 10; 4. if ( x > y) System.out. println(“y is greater”); else System.out. println(“x is greater”); 5. int i=5, j = 10 if ( (i < j) || (i=10)) System.out.println(“OK”); System.out.println(“not OK); 6. int x=0; while(x < 10) System.out.println(x); x ++; 7. for ( x = 0; x>= 10; x- -) System.out.println(x); 8. for (i = 0, i <= 25; i ++) System.out.println(i); System.out.println(“the value is “;x);
  • 3. 9. public int add(int x,int y) { int z=x + y; } 10. int a = 5 , b = 7 , c = 1; if (a > b || b > c) System.out.println(a + “ is greater”); 11. int a =90, b = 45, c = 45 if(a = = 90 && b = = 90 && c = = 90) System.out.println(“Right angle Triangle”); 12. double p =1000.00, t = 5.0, r = 10.5; I = p * r * t / 100; System.out.println(I); 13. double average = M1+M2+M3+M4 / 4; 14. String s = ‘computer’; 15. int l = “Good Morning”.length; 16. for (int x = 1; x < = 10 ; x++) { n = 1; System.out.println(n); n++; } correct the code to get 1 3 5 7 9 11 13 15 17 19 output. 17. int x, y, z; x = 6; y = 7; x + y = z; System.out.println(z); 18. int a[] = new int [10]; for( x =1 ; x<=15 ; x++) a[x] = x * x; 19. int n = integer.ParseInt(br.readline()); 20. String st = “School”; System.out.println(st.reverse( )); 21. int x = 5, y = 8, temp; temp = x; x = y; y = temp; System.out.println(x, y, temp); 22. int x[ ] = [3,6,8,4,7,0,4,1,5]; 23. int ar[ ] = [3,6,8,4,7,0,4,1,5]; System.out.println(ar.length()); Express the following in Java expression (1-y3 )0.5 √ (x2 – x1)2 + (y2 - y1)2 –b + (b2 -4ac)/2a 3x2 +2y [2011] x - y (x2 - 2y2 )3 (1 + x4 )0.25 a = (0.05 – 2y3 )/x - y A3 + B3 + C3 – 3ABC x1/3 √ l2 + b2 x – [ y – {+ (a + b – c – d)}] 3x2 y+2yx2 ( x – y)0.5 s = ut + ½at2 (a + b)n √3 + b √ 2as + u2 (2012) 5x * 7 – 5x 5x+2 – 5x+1 2AB + 2BC + 2CA X2Y2 + Y2Z2 + Z2 + X2