Part 1. of your question: If you don't specify a version there are various different outcomes:
a) you will get an error...
[ERROR] The project org.example:myproject:0.5-SNAPSHOT (D:srcmyprojectpom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for foo:bar:jar is missing. @ line 39, column 14
b) if you have defined the version in the dependency management of the project's parent's pom, then that version is taken. The parent of the project doesn't have to be an enclosing superproject. It can simply be a collection of appropriate definitions.
c) if another dependency of your project also depends on foo:bar, and specifies a version, then that version is taken. Maven 2 has a mechanism called transitive dependencies. If the version of a dependency is not explicitly specified for an artifact, it searches the dependency tree and uses the nearest definition in the tree. If there are two nearest definitions, then the first declaration wins (since maven 2.0.9).
Part 2.: I am not sure, but maybe the transitive dependency mechanism also works that way. But the documentation (as far as I understood it) doesn't mention that case.
But somehow I feel that the second part of your question doesn't make sense: I guess that in order to use an artifact as a dependency, you would have to build it first. So you'd have to know the version of the dependencies well before it is used as a dependency itself.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…