BuiltWithNOF
Read Code

What is the output for the following code? Put your FINAL answer in the box provided. BE CAREFUL!

public class TestPrep

{

public static void main( String args[] ) throws IOException

{

int a,b,c,wait;

a=4; b=7; c=9;

while (a < c)

{

System.out.println(a + " loop");

if ( a < b)

System.out.println("stop");

if ( a + b > c)

{

while ( a < b )

{

if ( a == 5)

System.out.println("stuff" + b);

b--;

if (b == a)

{

System.out.println("YES!");

a++;

}

System.out.println("again" + a);

}

a++;

}

a+=2;

System.out.println("stop");

}

if ( b < 7)

{

b++;

System.out.println(a);

}

System.out.println("more");

}

}

What is the output for the following code? Put your FINAL answer in the box provided. BE CAREFUL!

public class TestPrep

{

public static void main( String args[] ) throws IOException

{

int a,b,c,wait;

a=2; b=6; c=9;

while (a < c)

{

System.out.println(a + " loop");

if ( a < b)

System.out.println("stop");

if ( a + b > c)

{

while ( a < b )

{

if ( a == 5)

System.out.println("stuff" + b);

b--;

if (b == a)

{

System.out.println("YES!");

a++;

}

System.out.println("again" + a);

}

a++;

}

a+=2;

System.out.println("stop");

}

if ( b < 7)

{

b++;

System.out.println(a);

}

System.out.println("more");

}

}

 

Put your final correct answer for the output in the box provided:
intA = 5; intB = 1; intC = 8;
while (intB < intC)
{
System.out.println ("yes" + intC);
intB = intB + 1;
if (intA > 3)
{
System.out.println ("more");
while (intA > intB)
{
System.out.println ("do it" + intB);
if (intB < 4)
{
intC = intC - 1;
System.out.println (intC);
if (intA == 5)
{
System.out.println ("done");
}
System.out.println ("finish");
}
intB++;
intA-=1;
}
System.out.println ("stop" + intB);
}
if (intC < 3)
{
System.out.println ("junk");
intC = intC - 1;
}
intC--;
}
 

 

 

import java.io.*;

public class OutTest1

{

   public static void main( String args[] ) throws IOException

   {

     int a,b,c,wait;

  a=4; b=11; c=9;

  if (a+2>b)

  {

  System.out.println("One");

  while (a<b)

  a++;

  }

  while ((b%a) <7)

  {

  System.out.println("junk" + a);

  a++;

  if (a == 6)

  System.out.println("is 6");

  c+=2;

  if (c==11)

  {

   c++;

   a--;

   System.out.println("NO");

   if (b>5)

 System.out.println("True");

  }

  System.out.println("again" + a);

  }

  if (c < 12)

  while ( c < 14 )

  {  System.out.println("stuff");

     c++;

 if (c>0)

{

 System.out.println("More");

 }

  }

 System.out.println("Repeat");

  wait = System.in.read();

 

   }

}

[Home] [Syllabus] [Sessions]