Question

Java What keyword would you write in the --?-- place, to get this code to write...

Java

What keyword would you write in the --?-- place, to get this code to write the output 10210?

int j = 20;

for (int i = 0; i < 5; i++)
{
    j = j/2;

    if (j == 5)
       --?--; 

    System.out.print(j);
}
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Dear Student,

we will write continue statement in the given empty place.Please check the BOLD keyword below.

=======================================================================================

Complete Program:

=======================================================================================

import java.io.*;

public class Print {
public static void main (String[] args) {
int j = 20;

for (int i = 0; i < 5; i++)
{
j = j/2;

if (j == 5)
continue;

System.out.print(j);
}
   }
}

=======================================================================================

Sample Output

Output:

10210

=======================================================================================

Kindly Check and Verify Thanks..!!!


}

Add a comment
Know the answer?
Add Answer to:
Java What keyword would you write in the --?-- place, to get this code to write...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • 1. What is output by the following code? String s0 = "Java"; int i1 = s0.indexOf('a');...

    1. What is output by the following code? String s0 = "Java"; int i1 = s0.indexOf('a'); int i2 = s0.indexOf('a', i1); int i3 = s0.indexOf('a', i1 + 1); System.out.print(i1 + " " + i2 + " " + i3); 2. What is output by the following code? String s1 = "Java"; String s2 = ""; for (int i = 0; i < s1.length(); i++) { s2 += s1; } System.out.print(s2);

  • 5. What is the Output? (2 x 5p each -10p) For cach of the following code snippets write down what...

    for java 5. What is the Output? (2 x 5p each -10p) For cach of the following code snippets write down what will be printed on the screen. (a) for(int a-0; a<5; a++) for (int b-0 b

  • JAVA 5) What is the output of the following code? int a = 70; boolean b...

    JAVA 5) What is the output of the following code? int a = 70; boolean b = false; if(a >= 70) { System.out.print(1); if(b==true) { System.out.print(2); } } else { System.out.print(3); if(b==false) { System.out.print(4); } } System.out.print(5); 6) What is the output of the code above using these initial values? int a = 43; boolean b = false; 7) The following method is SYNTACTICALLY correct (meaning it will compile). True or false? public boolean method() { int value = 5;...

  • 1. What is the output of the following code segment? int array[] = { 8, 6,...

    1. What is the output of the following code segment? int array[] = { 8, 6, 9, 7, 6, 4, 4, 5, 8, 10 }; System.out.println( "Index Value" ); for ( int i = 0; i < array.length; i++ ) System.out.printf( "%d %d\n", i, array[ i ] ); 2. What is the output of the following code segment? char sentence[] = {'H', 'o', 'w', ' ', 'a', 'r', 'e', ' ', 'y', 'o', 'u' }; String output = "The sentence...

  • The following code is a Java code for insertion sort. I would like this code to...

    The following code is a Java code for insertion sort. I would like this code to be modified by not allowing more than 10 numbers of integer elements (if the user enters 11 or a higher number, an error should appear) and also finding the range of the elements after sorting. /* * Java Program to Implement Insertion Sort */ import java.util.Scanner; /* Class InsertionSort */ public class InsertionSortTwo { /* Insertion Sort function */ public static void sort( int...

  • please evaluate the following code. this is JAVA a. class Car { public int i =...

    please evaluate the following code. this is JAVA a. class Car { public int i = 3; public Car(int i) { this.i = i; } } ... Car x = new Car(7), y = new Car(5); x = y; y.i = 9; System.out.println(x.i); b. class Driver { public static void main(String[] args) { int[] x = {5, 2, 3, 6, 5}; int n = x.length; for (int j = n-2; j > 0; j--) x[j] = x[j-1]; for (int j...

  • Please explain how you get the output for each case. 3. What is the output of...

    Please explain how you get the output for each case. 3. What is the output of the following jave code fragments: a. intl A-(1,3,0,2,4) int temp = A[0]; for (int í=0; i< A.length-l; i++) A(幻-A(1+1); AI4]-temp; for (int i: A) System.out.print(ALi]" b. intll A-(3,0,2,4,1) int B new int [51: for(int i-o; ǐ< A.length; ǐ++) for (int i: B)System.out.print (B[i]"" C. int A A-new intl for (int i-0: i A.length-1; 1++) AI4] -temp; for (int i: A)System.out.print (A[ +"

  • in java please fix code between 14 and 20 to make the code compile Write a...

    in java please fix code between 14 and 20 to make the code compile Write a method swapArrayEnds() that swaps the first and last elements of its array parameter. Ex: sortArray = {10, 20, 30, 40} becomes {40, 20, 30, 10). The array's size may differ from 4. Display ari ay Values 1 pas [ pa: 6 public void displayValues(int [] arrayVals) { 7 int i; 8 9 for (i = 0; i < arrayVals.length; ++i) { 19 System.out.print(arrayVals[i] +...

  • Can you help me with this code in Java??? import java.util.Scanner; public class Main { public...

    Can you help me with this code in Java??? import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); int rows = 3; int columns = 4; int[][] arr = new int[rows][columns]; for(int i = 0; i < rows; ++i) { for(int j = 0; j < columns; ++j) { System.out.println("Enter a value: "); arr[i][j] = scan.nextInt(); } } System.out.println("The entered matrix:"); for(int i = 0; i < rows; ++i) { for(int j...

  • Please try to explain the answers as well. It will be highly appreciated. Output of the...

    Please try to explain the answers as well. It will be highly appreciated. Output of the following expression: 5 * 4 % 2 = ? Output of a loop: Example: What will be the output of the Java code (Assume all variables are properly declared.) num = 10; while (num <= 32)                 num = num + 5; System.out.println(num); What will be the output of the Java code (Assume all variables are properly declared.) public class test {   ...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT