class - Inheritance functions in java -
this question has answer here:
duplicate of disabling inherited method on derived class
this class codes:
class parent{ public bool sum(int a){return true;} public int mul(int a){return a*a;} }
and 2 classes extends parent class:
class derived extend parent{ //here child can see 2 methods of parent class , //i want see sum method in here , don't see mul method } class derivedb extend parent{ //here child can see 2 methods of parent class , //i want here see mul method. }
you can making mul
private method in parent class. mul method has visibility inside parent
class
class parent{ public bool sum(int a){return true;} private int mul(int a){return a*a;} }
Comments
Post a Comment