--
Shashank Dwivedi
Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
I tried it sir but can't do it.I have posted my program.Thanks for your help!Mohamed Sanaulla wrote:As said, you need to try out such queries by writing to a program. If at all you arent able to figure out even after writing a program, you can post the code here and get it clarified. It will help in learning the language in a much better way
--
Shashank Dwivedi
shashank dwivedi wrote:
I tried it sir but can't do it.I have posted my program.Thanks for your help!Mohamed Sanaulla wrote:As said, you need to try out such queries by writing to a program. If at all you arent able to figure out even after writing a program, you can post the code here and get it clarified. It will help in learning the language in a much better way
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
shashank dwivedi wrote:
I tried it sir but can't do it.I have posted my program.Thanks for your help!Mohamed Sanaulla wrote:As said, you need to try out such queries by writing to a program. If at all you arent able to figure out even after writing a program, you can post the code here and get it clarified. It will help in learning the language in a much better way
--
Shashank Dwivedi
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Akhilesh Trivedi wrote:An abstract method is meant to be overridden, why not make disp also abstract? Infact that is what you should be doing to support the fact that poly is an abstract class.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Mohamed Sanaulla wrote: area() method is abstract in Poly class.
Keep Smiling Always — My life is smoother when running silent. -paul
[FAQs] [Certification Guides] [The Linux Documentation Project]
Akhilesh Trivedi wrote:An abstract method is meant to be overridden, why not make disp also abstract? Infact that is what you should be doing to support the fact that poly is an abstract class.
--
Shashank Dwivedi
shashank dwivedi wrote:
Akhilesh Trivedi wrote:An abstract method is meant to be overridden, why not make disp also abstract? Infact that is what you should be doing to support the fact that poly is an abstract class.
ya I can but why then i can't use Interface? Just checking why can i call super class methods...
--
Shashank Dwivedi
shashank dwivedi wrote:
shashank dwivedi wrote:
Akhilesh Trivedi wrote:An abstract method is meant to be overridden, why not make disp also abstract? Infact that is what you should be doing to support the fact that poly is an abstract class.
ya I can but why then i can't use Interface? Just checking why can i call super class methods...
There is "super" keyword but i wonder why it is not working here?
Is there a way using Typecasting??
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Mohamed Sanaulla wrote:
shashank dwivedi wrote:
shashank dwivedi wrote:
Akhilesh Trivedi wrote:An abstract method is meant to be overridden, why not make disp also abstract? Infact that is what you should be doing to support the fact that poly is an abstract class.
ya I can but why then i can't use Interface? Just checking why can i call super class methods...
There is "super" keyword but i wonder why it is not working here?
Is there a way using Typecasting??
super() in your example is used to initialize the variables declared in the Poly class. And nothing related to invoking any of the methods in your Poly or Rect class.
You can try adding: disp() in the poly(int y, int y) constructor.
--
Shashank Dwivedi
shashank dwivedi wrote:
Oh sir you get me wrong.I am not talking about super i used in constructor rather i meant can i some how use "super" keyword to call non-abstract method in super class( which is abstract)?
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Mohamed Sanaulla wrote:
shashank dwivedi wrote:
Oh sir you get me wrong.I am not talking about super i used in constructor rather i meant can i some how use "super" keyword to call non-abstract method in super class( which is abstract)?
Sorry for not getting your query.
Secondly, did you try adding a super.methodName() in the disp() method?
--
Shashank Dwivedi
shashank dwivedi wrote:
Mohamed Sanaulla wrote:
shashank dwivedi wrote:
Oh sir you get me wrong.I am not talking about super i used in constructor rather i meant can i some how use "super" keyword to call non-abstract method in super class( which is abstract)?
Sorry for not getting your query.
Secondly, did you try adding a super.methodName() in the disp() method?
Yes it is working fine if i use it in child class but in know way i can access it from main class with any reference whether it is of parent class or child class.
--
Shashank Dwivedi
shashank dwivedi wrote:
shashank dwivedi wrote:
Mohamed Sanaulla wrote:
shashank dwivedi wrote:
Oh sir you get me wrong.I am not talking about super i used in constructor rather i meant can i some how use "super" keyword to call non-abstract method in super class( which is abstract)?
Sorry for not getting your query.
Secondly, did you try adding a super.methodName() in the disp() method?
Yes it is working fine if i use it in child class but in know way i can access it from main class with any reference whether it is of parent class or child class.
what if i do something like
parent ref;
ref.MethodName();
but it simply displays overridden method in child class.
Henry Wong wrote:
shashank dwivedi wrote:
shashank dwivedi wrote:
Mohamed Sanaulla wrote:
shashank dwivedi wrote:
Oh sir you get me wrong.I am not talking about super i used in constructor rather i meant can i some how use "super" keyword to call non-abstract method in super class( which is abstract)?
Sorry for not getting your query.
Secondly, did you try adding a super.methodName() in the disp() method?
Yes it is working fine if i use it in child class but in know way i can access it from main class with any reference whether it is of parent class or child class.
what if i do something like
parent ref;
ref.MethodName();
but it simply displays overridden method in child class.
If the subclass overrides a method, and doesn't provide an alternate way to get to it, then "no" -- in that example, there is no way to access a method that have been overridden. And this is true regardless of whether the superclass is abstract or not.
Henry
--
Shashank Dwivedi
shashank dwivedi wrote:
You cleared my all confusions i was trying to fix from last day.Thank you
But I managed to do that with a NULLPointerException which i handled.
Anyway thank you once again.
Mohamed Sanaulla | My Blog | Author of Java 9 Cookbook | Java 11 Cookbook
Did you see how Paul cut 87% off of his electric heat bill with 82 watts of micro heaters? |