in JAVA by
Can you achieve Runtime Polymorphism by data members?

1 Answer

0 votes
No, because method overriding is used to achieve runtime polymorphism and data members cannot be overridden. We can override the member functions but not the data members. Consider the example given below.

class Bike{  

 int speedlimit=90;  


class Honda3 extends Bike{  

 int speedlimit=150;  

 public static void main(String args[]){  

  Bike obj=new Honda3();  



Test it Now



Related questions

+1 vote
asked May 5, 2021 in JAVA by SakshiSharma
0 votes
asked Apr 8, 2021 in JAVA by SakshiSharma
+1 vote
asked May 6, 2021 in JAVA by SakshiSharma