Quantcast
Channel: Java this in parent and child not working as expected - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Nadim Baraky for Java this in parent and child not working as expected

$
0
0

You should create a getter method i.e. getS() in the Child class to retrieve "Child" when you call child.getS() in your main method. In this way, you override the getS() method that was inherited from the Parent class.


Viewing all articles
Browse latest Browse all 4

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>