...Continued...
Now let's consider Infotables and change return value type of ExampleA to INFOTABLE. Two options are possible:
Option One is when you made a typo or simply forgot to declare result variable. You already know what happens in this case -- the service will try to return an undefined, which does not exist natively in Java, this value will be wrapped into a UniqueTag literal object, and everything else will fail, because it will be trying to cast it to Infotable, which it isn't. Take a look at the attached screenshot, I'm sure you've seen it before:

In Option Two you declared result variable, but did not initialize it. Then the service will return... No, you're wrong. An empty Infotable without a data shape, which is essentially a half-cooked Infotable. The latter is a crucial detail, because what happens next is really hard to predict. For example, you can't AddRow to it, and it won't display correctly in Composer. The real problem is that some of those weird side effects will happen down the road (maybe you'll never even realize that you have an issue). We had some sleepless nights debugging and subsequently refactoring such cases.
...All of which brought us to a simple conclusion / best practice: Always initialize your variables as explicitly as possible. If a service is supposed to return an Infotable -- preinitialize result variable with a proper empty Infotable. Same for the strings. If you need to return a number -- return -1 by default, etc. If you really have to return an empty value, then return null explicitly -- this should minimize amount of type conversions that Rhino and ThingWorx will try to do for you. Finally, if there are exception thrown -- don't catch them until strictly necessary, to make sure that those empty values do not proliferate throughout your runtime.
Again, all of above is our own findings based on ThingWorx consulting experience, not validated by PTC R&D. This kind of helps us to have a concise picture of internal mechanics, but in reality it may work completely differently, so don't blame me if that's the case.
/ Constantine