logo Practice-It logo

BJP3 Self-Check 1.30: javaClub

Language/Type: Java classes method basics
Author: Marty Stepp (on 2013/08/24)

Consider the following program, saved into a file named Example.java:

 1  public class Example {
 2      public static void displayRule() {
 3          System.out.println("The first rule ");
 4          System.out.println("of Java Club is,");
 5          System.out.println();
 6          System.out.println("you do not talk about Java Club.");
 7      }
 8
 9      public static void main(String[] args) {
10          System.out.println("The rules of Java Club.");
11          displayRule();
12          displayRule();
13      }
14  }

What would happen if each of the following changes were made to the Example program? If there would be no change to the program, choose "nothing". If it would cause the program not to compile or run, choose "error". If it would change the program's output, choose "output". Treat each change independently of the others.

a) Change line 1 to:
public class Demonstration
b) Change line 9 to:
public static void MAIN(String[] args) {
c) Insert a new line after line 11 that reads:
System.out.println();
d) Change line 2 to:
public static void printMessage() {
e) Change line 2 to:
public static void showMessage() {
and change lines 11 and 12 to:
showMessage();
f) Replace lines 3-4 with:
System.out.println("The first rule of Java Club is,");

You must log in before you can solve this problem.


Log In

If you do not understand how to solve a problem or why your solution doesn't work, please contact your TA or instructor.
If something seems wrong with the site (errors, slow performance, incorrect problems/tests, etc.), please

Is there a problem? Contact a site administrator.