This is primarily a style issue, not a performance issue.
One advantage of assigning to a temporary variable (B b = a.test()) is that if you step through a debugger you can explictly see the variables value. Another advantage in my opninion is that if you call one method on an instance and later add calls to other methods the approach above looks cleaner (vs repetitive calls to a.test().doB()). If you did the second approach you would have to change existing code if you switch to (b.doB()) approach, however you wouldn't have to change existing code if you did the opposite switch.
Also, in some cases by assigning to a temporary variable you can make it clear what the particular instance will be used for. Here is an example.
A a = new A();
MyClass colorHolder=a.getHolder();
Color color=colorHolder.get(i);
That is more descriptive (though less abstract) than the following:
A a = new A();
Color color=a.getHolder().get(i);
Note also you can get a null pointer exception in this case if getHolder() can return a null.
Having said that I am consistent in doing this myself, so I would be interested in hearing advantages/disadvantages from others.
[ March 27, 2008: Message edited by: steve souza ]