Knowee
Questions
Features
Study Tools

.What will be the output of the program ?public class Test { public static void main(String [] args) { signed int x = 10; for (int y=0; y<5; y++, x--) System.out.print(x + ", "); }}10, 9, 8, 7, 6,9, 8, 7, 6, 5,Compilation fails.An exception is thrown at runtime.

Question

.What will be the output of the program ?public class Test { public static void main(String [] args) { signed int x = 10; for (int y=0; y<5; y++, x--) System.out.print(x + ", "); }}10, 9, 8, 7, 6,9, 8, 7, 6, 5,Compilation fails.An exception is thrown at runtime.

🧐 Not the exact question you are looking for?Go ask a question

Solution

The program will not compile. In Java, there is no 'signed' keyword. The correct declaration should be 'int x = 10;'. If you correct this, the output will be '10, 9, 8, 7, 6,'.

Similar Questions

What will be the output of the following program?public class Test{ public static void main(String args[]){ int i = 0, j = 5 ; for( ; (i < 3) && (j++ < 10) ; i++ ){ System.out.print(" " + i + " " + j ); } System.out.print(" " + i + " " + j ); }}0 6 1 7 2 8 3 80 6 1 7 2 8 3 90 6 1 5 2 5 3 5Compilation Error

Determine output:public class Test{ public static void main(String[] args){ int[] x = {1, 2, 3, 4}; int[] y = x; x = new int[2]; for(int i = 0; i < x.length; i++) System.out.print(y[i] + " "); }}

What will be the output of the program?public class Sample{    public static void main(String [] args)    {        int i = 10;        do while ( i < 10 )        System.out.print("The value of i is " + i);        while ( i > 10 ) ;    }}Select one:a.No output is produced.b.The value of i is 10 The value of i is 10c.Compilation errord.The value of i is 10

What is the output of the programme below?public static void main(String[] args) {     int x = 0;     while (x < 10) {          if (x & 2 == 0) {               System.out.print(x + “ “);          }          x++;     }}

What will be the output of the following code snippet?int x = 7;int y = x > 5 ? 10 : 5;System.out.println(y);Question 29Answera.7b.5c.10d.The code will produce an error

1/3

Upgrade your grade with Knowee

Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.