---------------------------------------------------------------------------------------------------
Question: Why final modifier cant be applied on constructor in Java?
Answer: If we apply final modifier on a method of superclass the subclass cant override that method.
As we know the constructors never inherits, so they cant be overriden by the subclass.
So in this scenario the explicit use of final modifier becomes unnecessary on constructor.
---------------------------------------------------------------------------------------------------
Question: Can we apply native modifer on constructors in Java? Justify your answer.
Answer: We cant apply native modifer on constructors.
native modifer is applicable for the methods only. native methods are declared in Java and defined in C/C++ generally.
The native methods are evaluated by JVM using JNI (Java Native Interface), the JNI does not understands the OOPS concepts, and we already know the constructors are associated with objects only.
---------------------------------------------------------------------------------------------------
Question: Why final modifier cant be applied on constructor in Java?
Answer: If we apply final modifier on a method of superclass the subclass cant override that method.
As we know the constructors never inherits, so they cant be overriden by the subclass.
So in this scenario the explicit use of final modifier becomes unnecessary on constructor.
---------------------------------------------------------------------------------------------------
Question: Can we apply native modifer on constructors in Java? Justify your answer.
Answer: We cant apply native modifer on constructors.
native modifer is applicable for the methods only. native methods are declared in Java and defined in C/C++ generally.
The native methods are evaluated by JVM using JNI (Java Native Interface), the JNI does not understands the OOPS concepts, and we already know the constructors are associated with objects only.
---------------------------------------------------------------------------------------------------
Thanks Sir... Keep sharing these valuable insights...
ReplyDeleteFinally clears all my doubts regarding modifiers related with constructors. Thanks sir :)
ReplyDeleteSuperb sir
ReplyDeleteVery useful updates...please keep sharing
ReplyDeleteThank u sir..
Hello Sir I want to crack American Multinational Technology Company interview and want get a job in this company. So Please provide me the IBM Interview Questions so that i crack this interview.
ReplyDeleteThanks for sharing you informationMedical Coding Training Hyderabad
ReplyDelete