java - The interface code is giving compile time error -
interface i1 { int = 10; void add(); void sub(); void del(); } interface i2 { void disp(); } class implements i1,i2 { void add(){...} void sub(){...} void del(){...} void disp(){ system.out.println(i); } } this code giving compile time error. don't know wrong code.
implicitly, i1.add() et al public. therefore in class must make them public:
public void add(){...} public void sub(){...} public void del(){...} public void disp(){ system.out.printf(i); } otherwise you'd get
cannot reduce visibility of inherited method test.i1 also, call printf() needs change to:
system.out.printf("%d", i); (the first argument format string.)
Comments
Post a Comment