You're creating an object of type foobar. The compiler only knows about the members defined for the class/interface foobar.
Remember, java is a static language, not dynamic. It doesn't check the object at runtime for what exists, it checks at compile time based on the type declaration.