logo Practice-It logo

BJP4 Self-Check 1.30: javaClub

Language/Type: Java classes method basics
Author: Marty Stepp (on 2016/09/08)

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      }
 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, 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:
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:
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.