Home » Interview » Technology

If sub class data member is hiding super class data member then how to access super class data member inside sub class methods?

Correct Answer: use super keyword super keyword points immediate super class Class Sample { int a =23; } Class Sub extends Sample { String a = "bablu"; void show() { Systemoutprintln(a); //bablu System out println(thisa); //bablu System outprintln(supera); //23 } } Class Demo { Public static void main(string[] args) { sub s = new Sub(); sshow(); } }

← Previous Question Next Question→

Discussion & Comments

No comments yet. Be the first to comment!
Join Discussion