Singe Interface implemented by multiple classes

The same interface can be implemented by more than one classes as shown below:

class ClassOne implements Interface1
{
      //Body of ClassOne
}

class ClassTwo implements Interface1
{
     //Body of ClassTwo
}

Lets implement this on Eclipse IDE:

1. Create Interface 'Interface1' under any project as shown below:



2. Create first class 'ClassOne' which implements the above created Interface 'Interface1' as shown below:



3. Create second class 'ClassTwo' which implements the same Interface 'Interface1' as shown below:



4. Create third class 'ClassThree' which implements the same Interface 'Interface1' as shown below:



5. Create another class 'MultipleClassesSingeInterface' to create objects for accessing the members of 'ClassOne', 'ClassTwo', 'ClassThree' class files as shown below:



6. Save and Run the 'MultipleClassesSingleInterface' class
7. Observe that the output is displayed in the console as shown below:



Download this project:

Click here to download the project containing the 'Interface1', 'ClassOne', 'ClassTwo', 'ClassThree' and 'MultipleClassesSingleInterface' files used in this post (You can download this project and import into Eclipse IDE on your machine)