This is wrong ! new foo(baa())
You cannot do this in Java, instead what you need to do is
new foo(new baa().bar()) .
This means you first create a reference (Object) of baa and call bar() method of that reference. Remember new keyword in Java is to create a new reference out of a class. It calls a Constructor method of the class and allocates memory for that reference.
Further in above case it passes whatever returned from bar() method as an argument to the foo class and in turn create a reference of foo class too.
This is a good start : [1]: http://docs.oracle.com/javase/tutorial/java/javaOO/index.html