This post originated from an RSS feed registered with Java Buzz
by Javin Paul.
Original Post: Difference between method and constructor in Java
Feed Title: Java67
Feed URL: http://www.java67.com/feeds/posts/default?alt=rss
Feed Description: Java and technology tutorials, tips, questions for all programmers.
What is difference between method and constructor in Java is
very common questions on beginner level Java
interviews with 2 to 3 year experience. Since constructor is kind of
special and it has it's own properties which separates it from any normal Java method,
this question make sense. Main difference between Constructor and Method is that,
you need to call method explicitly but constructor is called implicitly by Java
programming language during object instantiation. It doesn't mean you can not
call Constructor; if you have overloaded
constructor than you can call them using this
keyword as this() constructor, you can even call
super class constructor using super() keyword, in-fact that is
done automatically by Java compiler if no explicitly constructor is called and
that is known as constructor chaining in Java. Like many other beginner
level questions e.g. Vector
vs ArrayList, We will see difference
between method and constructor in Java in point form to understand
important properties of each of them clearly.