Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Java interfaces and memory accolcation

Suppose you have a class Delta that implements interface Alpha. Alpha has methods a, b, and c, and Delta defines an additional method d. If the line "Alpha object = new Delta()" is written, will the compiler allocate memory for the method d even though the reference will not be able to access it?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Yes, the memory will be allocated for the method ‘d’. It won’t be ‘visible’ if you try to access it via Alpha reference without casting. But because you are creating an object of type Delta the method ‘d’ is there.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading