I acheived Multiple Inheritence in JAVA !!!!!!!!

Hi,
Im in ob_imit2_a2 group. I can use member variables and methods of two(or more) classes in another class without importing them just like Multiple Inheritence in C++.
TECHNICAL COMMENTS REQUIRED
See Below
///////// Outer.java
public class Outer implements myInterface, myInterface2{
public Outer() {
System.out.println("outer class");
public void check()
     inter2.test();
     inter.test();
////////// myInterface.java
interface myInterface{
class interclass{
     interclass()
          System.out.println("SS");
     public void test()
          System.out.println("TEST");
public interclass inter=new interclass();
//////////myInterface2.java
interface myInterface2{
class interclass2{
     interclass2()
          System.out.println("SS 2");
     public void test()
          System.out.println("TEST 2");
public interclass2 inter2=new interclass2();
//////////// Main.java
public class Main {
public static void main(String abc[]) {
Outer o = new Outer();
     o.check();
}

Any and all variables declared in an interface are always implicitly public, static, and final; meaning that they are constants and NOT member variables. You can call these methods directly from the main method (a static scope) as well; meaning that they are not associated with any instance of the class Outer; i.e. they are NOT inherited.
The difference between inheritance (extending) and realization (implementing) is that when extending you inherit everything from your parent class, and while implementing you are taking up a role and agree to fulfill all the responsibilities (methods) of that role.

Similar Messages

  • Implementation of multiple inheritence

    hi
    i am goutam.how can we implement multiple inheritence in java.and how two super classes can be inherited in one sub class

    keep it to one thread, please!

  • Interfaces to replace multiple inheritence

    Howdy,
    I have, conceptually, the following situation: I have a Ball abstract class. The Ball has several
    concrete methods. It also has an abstract method getAppearance (that would somehow return how a
    Ball is visualized). I have several "adjective" subclasses that I would like to build from it, for example:
    SpikyBall, GlowingBall, ColorBall, etc. I would like these classes to be concrete.
    Additionally, I would like to have a concrete class of any permutation of this list of adjectives, for example:
    SpikyColorBall, GlowingColorBall, SpikyGlowingColorBall. I want to accomplish this
    using as little code rewriting as possible, and, hopefully, none at all.
    Using certain other single letter languages that I won't name here, I used Multiple Inheritence. A
    SpikyColorBall would inherit from both SpikyBall and ColorBall, who both inherited from
    Ball. I was told I could accomplish this in Java using interfaces instead of multiple inheritence, which
    Java doesn't support. How is this accomplished? Could you give me (or forward me to) a good
    example? Again, the power I'm looking for is multiple inheritence's code-reusability.
    As a side note, why did Java choose to use interfaces instead of multiple inheritence?

    Courtesy of yawmark...
    composition_v_inheritance
    Bruce Eckel, author of Thinking In Java, has this to say about composition vs. inheritance:
    When deciding between inheritance and composition, ask if you need to upcast to the base type. If not, prefer composition (member objects) to inheritance. This can eliminate the perceived need for multiple base types. If you inherit, users will think they are supposed to upcast.
    Choose composition first when creating new classes from existing classes. You should only used inheritance if it is required by your design. If you use inheritance where composition will work, your designs will become needlessly complicated.
    Bill Venners: Composition versus Inheritance
    Use inheritance (of implementation) only when the class satisfies the following criteria:
    1) "Is a special kind of," not "is a role played by a";
    2) Never needs to transmute to be an object in some other class;
    3) Extends rather than overrides or nullifies superclass;
    4) Does not subclass what is merely a utility class (useful functionality you'd like to reuse); and
    5) Within PD: expresses special kinds of roles, transactions, or things.
    -- from Java Design: Building Better Apps and Applets (2nd Edition), by Peter Coad and Mark Mayfield

  • Why  multiple inheritence is avoided in java.

    why multiple inheritence is avoided in java.
    r there any advantages in this???
    can u briefly explain with programming so that it will be clear.

    Here is one of several discussions of this topic to be found on the web:
    http://csis.pace.edu/~bergin/patterns/multipleinheritance.html

  • Is Java allow multiple inheritence?

    Hi,
    I am having class A and class B, and class A exteds Class B. All class in Java extends Object class by default,
    1. class B extends one class Object
    2. class A extends two classes class B and class Object.
    Now class A extending two classes is it correct?
    Kindly help me.

    RajivGuna wrote:
    Hi,
    I am having class A and class B, and class A exteds Class B. All class in Java extends Object class by default,
    1. class B extends one class Object
    2. class A extends two classes class B and class Object.
    Now class A extending two classes is it correct?
    Kindly help me.What you described isnt multiple-inheritence , more like multi-level inheritence .Java allows a maximum of one direct superclass for a class , and the situation you described doesnt violate that restriction.

  • Multiple inheritence occured in java?

    we know java doest support multiple inheritence
    we know the super class for all java classes is Object
    ex:
    class A
    class B extends A
    here A extending Object
    and B extending Object(by default ) and extendin A
    is multiple in heritence occured
    if u say its multilevel inheritence how will u prove that programatical?

    we know java doest support multiple inheritence
    we know the super class for all java classes is
    Object
    ex:
    class A
    class B extends A
    here A extending Object
    and B extending Object(by default ) and extendin A
    is multiple in heritence occuredno, multiple inheritance occurs when a type directly inherits from more than one other type
    if u say its multilevel inheritence how will u prove
    that programatical?huh ?

  • Multiple version of Java on one machine

    Is it possible to have multiple versions of Java co-exist on the same XP Pro machine?
    Here is our scenario: we have apps that use Java 1.5, but we have one critical app that doesn't support that version yet. It has to use the 1.4 version. Is there a way to allow both versions to exist and be usable for their respective apps? If so, how?
    Thank you.

    I can't, however it's never a good idea to have
    multiple versions of Java on one machine. Try and
    standardise if possible. If OP used JAVA_HOME as you
    often suggest, then he would be knackered wouldn't
    he? JAVA_HOME can only point to one JDK. Your
    advice is conflicting kaj.Nope. JAVA_HOME should always be defined in the start script/file for a java application, so it's not set per system. It's very common that companies have applications that requires different JDK/JRE versions, and it's usually very expensive to upgrade all applications (if it's possible at all). You can of course also alter the PATH variable if you want to in the script.
    /Kaj

  • Is multiple inheritence is possible in sap?

    can any one help me?
    is multiple inheritence possible in sap ?
    and is one class can extend multiplre interfaces??

    Hi,
            Multiple inheritance as a concept is not allowed in ABAP Objects. But the effect and behaviour that you get by multiple inheritance is acheviable in ABAP objects with the help of interfaces. As follows.
    An interface can inlcude more than one interface, that is an interface can extend more than one interface. Now if you have say interface1, interface2 and interface3.
    interface4 can be declared to include all three other interfaces. And you class can include this interface4 in its interfaces tab.
    Due to this your class gets the behviour(methods) that is defined in all ther interfaces. You can assign an object of this class to a reference of any one of these four interfaces. So one object can react to method calls on four different interfaces which is what you want to achevie in multiple inheritance.
    Regards,
    Sesh

  • Multiple Inheritence/Const Compiler bug

    I'm encountering what appears to be a bug when mixing multiple inheritence & const/non-const methods. The compiler (WorkShop 6 Update 2) is accepting the following ill-formed code :
    class Base1 {
    int a; //If Base1 is empty, the problem doesn't appear.
    //A virtual function elicits the bug as well.
    class Base2 {
    public:
    void mutator() { //non-const method   
    class Derived : public Base1, public Base2 {
    class Foo {
    private:
    Derived my_derived;
    public:
    void f() const {
    my_derived.mutator();
    int main (int argc, char* argv[])
    Foo my_foo;
    my_foo.f();
    Note how f() in class Foo is const, yet attempts to call mutator(), a non-const method that my_derived gets via inheritence to Base2. This is ill formed and should, I believe, yield a compiler error. If the code is just subtly changed, the correct error will appear. For instance, if Base1 is empty, the appropriate error appears. Alternatively, if Base2 appears before Base1 in Derived's inheritence list, then the appropriate error appears.
    Is this a known problem? Is there a patch available? I'm very concerned that this bug is allowing const-incorrect code to be developed unknowingly, as it has in the project I'm involved in.
    Thanks in advance for giving this your attention!
    David Michael

    The bug report hasn't been filed yet. If you have contract with Sun, please follow the service channel to file the report. Otherwise, I can do it for you. Please provide:
    - O/S version
    - Architecture
    Please notice that if you don't have contract with sun, the bug might be in a low priority.
    - Rose

  • Run multiple versions of Java

    Hi,
    We run Oracle 12.1.3, Business Objects, Agile and a few bank applications that all require different versions of Java.
    What is the best way to run multiple versions of Java on one laptop so our users can access all of the Java based applications?
    Business Objects requires Java 6, and the bank application require Java 8.
    Thank you.

    Given that that's been possible for over a decade, there's no need for such "tools". All you need is knowledge of your operating system.

  • Will Java 8 include a Tool that will allow multiple versions of Java to run together?

    We continue to struggle with an absolute need to run multiple versions of JAVA at the same time on the same PC.
    Will JAVA 8 include a Tool, add--on, extension, something, that will allow this requirement to be executed?

    Given that that's been possible for over a decade, there's no need for such "tools". All you need is knowledge of your operating system.

  • Zip and extract multiple files using java program

    how can i zip and extract multiple files using java program.

    Hi,
    Look into the java.util.zip and java.util.jar they expose methods to manipulate zip and jar files.

  • How to retain socket connection for multiple requests in java 1.3

    Hi All,
    My problem is to retain client socket connection without opening and closing socket connection for every request.I want to open the socket connection once and send multiple requests one after the other based upon the response over the same socket.Finally I want to close the socket only after completing all my requests and receiving respective responses.I don't want to open and close the socket for each request and response.While at the same time I expect the socket to send each request only after receiving the response for the previous request.
    I am using java 1.3 and I am looking for the solution in same version.
    Please help me .
    Thanx in advance.

    Look at my response to "Telnet to Unix box from Java"
    http://forum.java.sun.com/thread.jsp?forum=31&thread=437231
    on "Java Programming" forum. It does exactly that to run the signon and a command. It would be easy to extend it to do multiple commands.

  • Multiple inheritance in Java

    Why it is sometimes said that interfaces provide a form of multiple inheritance?
    Do you agree that interfaces can provide multiple inheritance? Explain.
    Some people say that Java does not support multiple inheritance, and others: a class can implement more than 1 interface. Isn't that multiple inheritance?
    Thanks

    >
    Some people say that Java does not support multiple
    inheritance, and others: a class can implement more
    than 1 interface. Isn't that multiple inheritance?Sort of, but you don't inherit any implementation from an interface.

  • No multiple inheritance in Java. Interfaces used.

    Hi,
    In java a class can extend only one class while the interface can extend any number of interfaces.
    Class extending only one class avoids multiple inheritance.
    Can you explain me the reason of avoiding this in classes and allowing interfaces to extend any number of interfaces ?

    Hi,
    In java a class can extend only one class while the
    interface can extend any number of interfaces.
    Class extending only one class avoids multiple
    inheritance.
    Can you explain me the reason of avoiding this in
    classes and allowing interfaces to extend any number
    of interfaces ?The real question is: do you have a need for multiple inheritance?
    If so, I would be glad to hear about this concrete problem.

Maybe you are looking for

  • How to get sound from phone when bluetooth connected

    Easily paired my Plantronic bluetooth headset - piece of cake.  However, if I'm not on the phone, I don't keep it on my ear.  Sounds, except phone ringing, only come thru the headset whe it is on.  I would like to hear the other sounds (i.e. notifica

  • Adding attachments to equipments (massive)

    Hi all, I need to attach n documents to n equipments, just like it is possible to do by transaction IE02, but with a massive process (possibly in background with an input file). Since this functionality is not available using SHDB I cannot use BDC. C

  • What week is my MBP?

    Hello, Have been browsing through the forum and see everyone refering to their MBP's in weeks. i.e. "min's is a week 14". What does this mean? (I assume it refers to the week of manufactire after the MBP was first released?). How can I tell what week

  • Acknowledgment for SO

    Hi, I understand that using File to IDOC scenario, we can post the PO data (ORDERS.ORDERS05) from legacy sys to R/3 backend as IDOC. My doubt is, do we need to implement IDOC to File scenario again in order to give acknowledgement to the customer (le

  • Unable to install Premiere Elements 13 upgrade

    During the zip file extraction, it quickly jumps from 20% to 97% and then reports: "A problem occurred while extracting some files. Check available space on your computer and the write privileges on the destination folder." There is over 800GB availa