Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

Java question - access methods of a sub class?

The app has a design similar to

A

- -> interface

B

- -> extends

C

I am getting an object of type A and I want to access a public method from C. So When I typecast, the build fails giving

*** Semantic Error: the import "B" is not valid, since it does not name a type in a package.

Can some one suggest a solution?

thanks

3 Answers

Relevance
  • 1 decade ago
    Favorite Answer

    Ok, just say you have this.

    public class A extends C implements B {

    public void aMethod() {

    super.cMethod(); // Calls the method in C

    }

    }

    public class C {

    public void cMethod() {

    }

    }

    public interface B {

    public void bMethod();

    }

    Hope that helps.

  • MDB
    Lv 5
    1 decade ago

    If C is the interface and B extends C, then A must implement B in order to access a public method from C, as long as the method in C is defined in B.

    public class A implements B

    {

    ...

    }

    Source(s): ... I think.
  • barela
    Lv 4
    4 years ago

    permit's see... one million. fireplace all women folk instructors thinking the Bible says that ladies folk shall no longer instruct over a guy. 2. Make the Bible the only textbook allowed. 3. Stone sinners. this implies everyone who lies, steals, commits adultery(which, biblically speaking, skill lots as being with the different intercourse unchaperoned), worships graven pictures(this implies not extra drooling over attractive Hollywood stars etc), covets(so in case you want some thing somebody else has, you're executed), etc. 4. Tear down our colleges and replace them with church homes so as a exchange of going to college standard to benefit, you bypass to church.(Eh, i think this kind of is going with #3) 5. Serving biblically authorized lunches(not extra pink meat chops and ham sandwiches as pink meat is forbidden interior the Bible) 6. submit the ten Commandments interior the hallways(regardless of the reality that i've got heard some colleges easily attempt to flee with this) 7. the place there have been as quickly as pictures human beings Presidents, placed in basic terms a photograph of Christ. 8. for the period of Lent, make fasting a call for thus see you later snacktime(for youthful childrens) and lunches. 9. instead of faculty counselors, make the youngsters bypass to confession. 10. For celebrating trip journeys, cause them to in basic terms celebrate non secular ones and in basic terms the non secular factors. Halloween? Buh-bye. Thanksgiving? an afternoon of prayer. Christmas? Sayonara Santa and provides. Have a Nativity opposition. Easter? not extra eggs and bunnies, you get a activity of the keenness. 11. Require daily prayers or recitation of issues such as a results of fact the Lord's Prayer. 12. instead of instructors, provide them monks/ministers/etc. 13. container journeys are to monasteries, places of non secular importance, instead of to someplace relaxing. 14. Separate boys and ladies classes, make the girls placed on long hair and placed on dresses or "modest" clothing. No makeup, no rings...till it extremely is a crucifix or some thing non secular, of direction. 15. Homework comprises essays as to why different religions are going to hell and the only issues worse than yet another faith is not any faith in any respect, or on how someone can finally end up in hell or how they are in a position to keep away from it, etc. sixteen. earlier nutrients, extremely everyone ought to declare grace/table prayers, and people who do no longer pray, do no longer eat. actually, i ought to probable save going all day if i attempted...

Still have questions? Get your answers by asking now.