happytoday wrote:
Eric Sosman wrote:
happytoday wrote:
I am testing interface but really I can not apply what is explained in
oracle [sic] tutorials . Could you please explain why I have errors with
this code :
[...]
What "errors" do you have? For me, the code compiles just
fine, and runs [...]
prog01_BicycleDemo_interface_trial01.java:62: printresults() in
ACMEBicycle cannot implement printresults() in Bicycle; attempting to
assign weaker access privileges; was public
void printresults()
^
Aha! So by "this code" you meant "some other piece of code
altogether," right? Do you know how many times "ACME" appears
in the code sample you posted? Z E R O times, that's how many.
Unfortunately, I am not sufficiently skilled to debug code
that I cannot see. My guess (but I'm only guessing) is that
you've converted Bicycle from a class to an interface, thus
making its methods public automatically even if you don't use
the `public' keyword. Then (still guessing) you've written an
ACMEBicycle class that implements Bicycle, and you've tried to
give it an implementation of the printresults() method specified
by the Bicycle interface. But the interface says printresults()
must be a `public' method, while ACMEBicycle's printresults()
isn't marked `public'.
There are other possible explanations, but I'm tired of
guessing about unseen code and my Magic 8 Ball has a virus.
answers "Yes" or "No" questions.
Fortunately the OP asked a "Yes" or "No" question.