Organizational Research By

Surprising Reserch Topic

What is the difference between a constructor and method?


A constructor is called implicitly whenever an object is created. But a method is to be called explicitly.
 
A constructor cannot be static but a method can be. When the following code is compiled. the compiler complains "modifier static not allowed here".
 
 
public class cunstest extends Test
{
  public static Demo() {}
}
 

asked Sep 13, 2013 in Core java by itkbc
edited Sep 12, 2013
0 votes
25 views



Related Hot Questions

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please log in or register.

...