top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

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

+1 vote
72 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
Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...