-1

I have a general question. Let's say I have the following structure:

interface IFirst{}
class A implements IFirst{}
class B extends A{}

And furthermore the following class:

class TestClass{
    public dummy(IFirst data){}
 }

Which kind of Objects does the dummy-Method accept then?

Yaman Jain
  • 1,254
  • 11
  • 16
vogs
  • 51
  • 1
  • 6

1 Answers1

0

Its simple, every Object that somehow implements the interface IFirst. In your example that is A and also B since B extends A which is an IFirst, so B is also an IFirst.

Here's another example, the following structure:

interface Animal
class Dog implements Animal
class Cat implements Animal
class Husky extends Dog
class SmallDog extends Dog
class Chihuahua extends SmallDog

Makes sense that everything is of type Animal here :)

Zabuzard
  • 25,064
  • 8
  • 58
  • 82