Java Method static method Question 1

Question

What is the output of the following code?


public class Main {

  String greeting = "Hello";

  public static void main(String args[]) {

    System.out.println(greeting);

  }// w  ww  . j  av a 2 s . c o  m

}


Compile time error
Cannot make a static reference to the non-static field greeting



PreviousNext

Related