top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Can you use this() and super() both in a constructor?

+1 vote
559 views
Can you use this() and super() both in a constructor?
posted Oct 30, 2015 by Karthick.c

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

2 Answers

+1 vote

There is a difference between super() and this() . Constructor must always be the first statement. SO we can not have two statements as first statement, hence either we can call super() or we can call this() from the constructor, but not both.

answer Nov 2, 2015 by Shyam
+1 vote

We cannot use both super and this in the same method.
They have to be stated in the first line of the method.
So either of them can be used at a time.

answer Feb 29, 2016 by Josita Sarwan
...