What will be the result of compiling the following program?.
public class Main { long var; public void Main(long param) { var = param; } // (1) public static void main(String[] args) { Main a, b;/* w w w .ja v a2s . c o m*/ a = new Main(); // (2) b = new Main(5); // (3) } }
Select the one correct answer.
(c)
A compilation error will occur at (3), since the class does not have a constructor accepting a single argument of type int.
The declaration at (1) declares a method, not a constructor, since it is declared as void.
The method happens to have the same name as the class, but that is irrelevant.
The class has an implicit default constructor, since the class contains no constructor declarations.
This constructor is invoked to create a Main object at (2).