Each number is a complete Java program. If you were to run this program, what output would show up on the screen?
Type your answers in the box. Read each question carefully. Your answers must be exact.
1.
class MyJavaProgram{
public static void main(String[] args){
System.out.println("Tacos");
}
}
2.
class MyJavaProgram{
public static void main(String[] args){
String book = "Cat in the Hat";
System.out.println(book);
}
}
3.
class MyJavaProgram{
public static void main(String[] args){
String book = "Frankenstein";
System.out.println(book + " " + book);
}
}
4.
class MyJavaProgram{
public static void main(String[] args){
String book = "Tale of Two Cities";
System.out.println("book");
}
}
5.
class MyJavaProgram{
public static void main(String[] args){
int i = 5;
System.out.println(i);
}
}
6.
class MyJavaProgram{
public static void main(String[] args){
int x = -3;
int y = 6;
System.out.println(x + y);
}
}
7.
class MyJavaProgram{
public static void main(String[] args){
int s = 4;
if(s == 4){
System.out.println("FOUR");
}
else {
System.out.println("FIVE");
}
}
}
8.
class MyJavaProgram{
public static void main(String[] args){
int j = 1;
if(j > 0){
System.out.println("CLICK");
}
else if ( j == 2){
System.out.println("CLICK");
}
System.out.println("CLICK");
}
}
9.
class MyJavaProgram{
public static void main(String[] args){
int j = 1;
int k = 2;
if(j != k){
System.out.println("1");
}
else if (k != j){
System.out.println("2");
}
else{
System.out.println("3");
}
System.out.println("4");
}
}
10.
class MyJavaProgram{
public static void main(String[] args){
int i = 0;
int j = 1;
int k = 2;
if(i == 0){
System.out.println(i);
}
if(j == 1){
System.out.println(j);
}
if(k == 2){
System.out.println(k);
}
}
}
11.
class MyJavaProgram{
public static void main(String[] args){
String x = "X";
String y = "Y";
System.out.print(x);
System.out.print(y);
}
}
12.
class MyJavaProgram{
public static void main(String[] args){
String a = "A";
String b = "B";
String c = "C";
System.out.print(c + a + b);
}
}
13.
class MyJavaProgram{
public static void main(String[] args){
String a = "C";
String b = "B";
String c = "A";
System.out.print(c + a + b);
}
}
14.
class MyJavaProgram{
public static void main(String[] args){
for(int i = 0; i < 5; i++){
System.out.print(i);
}
}
}
15.
class MyJavaProgram{
public static void main(String[] args){
for(int i = 5; i >= 0; i--){
System.out.println(i);
}
}
}
16.
class MyJavaProgram{
public static void main(String[] args){
String h = "horse";
for(int i = 5; i >= 0; i--){
System.out.println(h);
}
}
}
17.
class MyJavaProgram{
public static void main(String[] args){
String d = "dynomite";
for(int i = 5; i >= 0; i--){
System.out.println(i);
}
System.out.println(d);
}
}
18.
class MyJavaProgram{
public static void main(String[] args){
for(int i = 0; i < 20; i++){
if(i % 2 == 0){
System.out.print(i + ", ");
}
}
}
}
19.
class MyJavaProgram{
public static void main(String[] args){
String count = "";
for(int i = 5; i >= 0; i--){
count += "count" + i + " ";
}
System.out.println(count);
}
}
20.
class MyJavaProgram{
public static void main(String[] args){
int x = 7;
for(int i = 0; i < 22; i++){
if(i % x == 0){
System.out.print(i + ", ");
}
}
}
}