|

Return to Unit Menu | Java Main Page |
MathBits.com |
Terms
of Use | Java Resource
CD
On-Line Work with Conditionals
|
What screen output
is produced by each of the following program fragments?
Check your answer.
|
| 1. |
num = 5;
if(num>=5)
{
System.out.println("Java Rules!");
}
System.out.println("Done."); |
|
|
| 2. |
num = 3;
if(num>=5)
{
System.out.println("Java Rules!");
}
System.out.println("Done."); |
|
|
| 3. |
num=5;
if(num<=5)
{
System.out.println("Java Rules!");
System.out.println("Done.");
} |
|
|
| 4. |
num=5;
if(num<=5)
{
System.out.println("Java Rules!");
System.out.print("Done.");
}
System.out.println("ABC"); |
|
|
| 5. |
num=9;
if(num<=5)
{
System.out.println("Java Rules!");
System.out.println("Done.");
}
System.out.println("Howdy"); |
|
|
| 6. |
if(true)
System.out.print("10");
System.out.print("20");
if(false)
System.out.print("30");
System.out.print("40"); |
|
|
| 7. |
if(false)
{
System.out.print("This is ");
System.out.print("never printed.";
} |
|
|
| 8. |
if(false)
System.out.print("This is ");
System.out.println("never printed."); |
|
|
| 9. |
Given the
following information:
int a = 1;
int b = 2;
int c = 3;
int d = 1;
determine whether the following statements are TRUE or FALSE:
a) a = = b
b) b != d
c) c <= b
d) a < c
e) a = = d
f) c > a
g) a >= c
|
|
|

Return to Unit Menu | Java Main Page |
MathBits.com |
Terms
of Use |
Java Resource
CD
|