top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Can we override constructor in Java? If yes then how, if no then why?

+3 votes
166 views
Can we override constructor in Java? If yes then how, if no then why?
posted May 2, 2015 by anonymous

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

2 Answers

+1 vote

No, You cannot override constructor of super class in sub class, In java overriding applicable to only instance methods as constructor in not treated as instance method it is specifically used to create object for the class

answer May 21, 2015 by Venkatesh B
0 votes

In Java, you can subclass (use extends keyword) or implement an interface.
You can also override the constructor including default constructor to write own code (generally for initialization).
Exceptions in Java are the classes that are singleton class or having private constructor, e.g Maths class.

answer May 4, 2015 by Priya Ranjan Kumar
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
...