That is a code design decision you have to make. You could have it set just in A or just in B, if the weight is associated with one or the other. You could have it check whether it is already set, e.g.
if (weight < 0) {
weight = getMyWeight()
}
which could be hidden inside a class method to avoid code duplication. Or you could leave it as it is, if getting the weight is not too expensive. You can change the order they are called in the constuctor for B to ensure one is called last if they both are.