How should the line 6 of the following code be modified so that the compilation error does not occur (select all that apply)?

1:  class Class1 
2:  { 
3:      int total = 0; 
4:      public static void main( String[] args ) 
5:      { 
6:          doIt(); 
7:      } 
8:      void doIt() 
9:      { 
10:         for ( int i = 0; i < 5; i++ ) total += i; 
11:         System.out.println( total ); 
12:     } 
13: } 
 
Explanation
An instance of class should be created in order to call non-static method from a static one.
It remains to recall that class is a keyword and it cannot be used as a variable name.
Java
Java Quiz
Start Quiz

or Read more about Java Quiz

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback