Constructor:
|
Method
|
1. Constructor
is a special method of a class but can’t be invoked directly by method call.
Java
doc. Says (A class contains constructors that are invoked to create objects
from the class blueprint.)
|
Methods are member of a class.
|
2.
It is not a member of a class as it can
neither be inherited nor invoked using dot (.) operator.
|
Dot (.) operator is used to invoke Non static methods via object and
static methods via class name.
|
3.
It has no explicit return type.
|
It has explicit return type, if there is nothing to return, the
return type must be void
|
4.
It has the same name as its class name.
|
Can have same name as its class name, but the existence of return
type makes it a method (unfortunately looks like constructor).
|
5.
It is used to initialize the objects, members
of object and then execute statements if any.
|
Used to execute statements.
|
6.
A no-argument, Default constructor is provided
by compiler when no explicit constructor is there. In such case instance
members are initialized with their default values (numeric data types are set
to 0, char to ‘\0’ and reference variable to null).
|
Local variable must be initialized explicitly.
|
7.
If there is no this() as the first statement,
super() will be there as first statement in the constructor.
|
‘this’ is implicitly invoked on all the member in non-static methods,
but need explicit invocation in case of name confliction.
Syntax: this.x, this.go()
|
8.
The default constructor will call the default
constructor of its super class due to presence of super() as its first
statement.
|
‘super’ can be used to explicitly invoke member of super class
(specially used either in case of name conflict or to call method of super
class when overridden in sub-class )
syntax:
super.member: when name
conflict
super.method(args if any) : when overriden
|
9.
A constructor can never be abstract or static.
|
A method is of two types defined (implemented) or undefined (abstract). The method implementation can be further
categorized as static or non-static. An abstract method can’t be
static or final.
|
10.
Can be specified as public, none (default),
protected or private.
|
Access-specifier public, none (default),
protected or private are applicable.
|
11.
Can’t be
final ,
native , or synchronized . (Constructor can take only access
specifier) |
Can be final, native, static or synchronized.
|
12. Can
be invoked by either
a.
new ClassName()
b.
this(args if any)
c.
super(args if any)
d.
getInstance()
|
Can be invoked by Class name in case of static
method or by object/this in case of non-static method.
|
If you could click on some of the google ads you see on the right side. It will help me to run this blog and motivates me ;)
Please check the 6th definition its wrong........
ReplyDeleteDinesh Singh Delhi >>>+918512023149
This comment has been removed by the author.
Deletetell me how you think 6th number is wrong.
DeleteConfusing :@
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteinstance members are copied to the objects.
ReplyDeletestatic members are not copied to the objects
What happen with the constructors???
If they get copied to the objects.. how can they access static members?
If they do not get copied to the objects... means they behave like static members. Then how do they access instance members?
Non-static member(instance member) resides with instance, however static member resides with class in class loader area.
DeleteI enjoy, result in I found exactly what I used to be looking for. You’ve ended my 4 day long hunt! God Bless you man. Have a nice day. Bye
ReplyDeleteJual Septic Tank
Tangki Fiberglass
I have read your blog its very attractive and impressive. I like it your blog.
ReplyDeleteJava Training in Chennai Java Training in Chennai | Core Java Training in Chennai | Java Training Institutes
Online Java Training Java Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai
The blog gave me idea about constructor and methods Thanks for sharing this post
ReplyDeleteJava Training in Chennai
really you have posted an informative blog. it will be really helpful to many peoples. thank you for sharing such kind of an interesting blog. so keep on sharing such kind of an interesting blogs.
ReplyDeletedot net training in chennai
Really happy to seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.
ReplyDeleteData science Course Training in Chennai |Best Data Science Training Institute in Chennai
RPA Course Training in Chennai |Best RPA Training Institute in Chennai
AWS Course Training in Chennai |Best AWS Training Institute in Chennai
Devops Course Training in Chennai |Best Devops Training Institute in Chennai
Selenium Course Training in Chennai |Best Selenium Training Institute in Chennai
Java Course Training in Chennai | Best Java Training Institute in Chennai
Great Blog thanks for the post Very useful Information
ReplyDeleteIOT training in cehnnai | IOT training course chennai
Css training in chennai | Css course in chennai
C++ training in chennai | C++ Training course in chennai
Awesome! Education is the extreme motivation that open the new doors of data and material. So we always need to study around the things and the new part of educations with that we are not mindful.
ReplyDeleteJava training in Chennai
Java Online training in Chennai
Java Course in Chennai
Best JAVA Training Institutes in Chennai
Java training in Bangalore
Java training in Hyderabad
Java Training in Coimbatore
Java Training
Java Online Training
Easeus data recovery Whole crack with license code 100 percent free Download is simply one of the greatest data recovery software systems. EaseUS Data Recovery 12 Entire latest version zero cost Download + Splendid & cute patch often is the Totally no cost Version. https://freeprosoftz.com/easeus-data-recovery-pro-license-code-crack/
ReplyDeleteAny animal can take a gander at the WiFi Password Hacker Online segment in the graph and might want to utilize it free of charge. https://crackdj.com/wifi-password-hacker/
ReplyDelete
ReplyDeleteYou should never compare your achievements to that your sibling, it goes against the very ethos of the relationship. Wish everyone a happy Sister’s Day. Sister Day 2022
Sylenth1 is the quality and execution that it can accomplish. It is a fundamental containing differences which are uniform. It utilizes imaginative strategy reliable in Draw progress top tier. Draw in join the music test. Following the blending of such music the impact is that the past music records turn sound at a cerebrum blowing level. .Sylenth1 Crack Software.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteKindly Visit my website for latest movies.
ReplyDeletewatchasiantv