Where can an object be instantiated and assigned inside a class? i.e does the assignment have to take place inside one of the class methods?
public class Foo{
Bar b1 = new Bar();
Bar b2;
void Foo(){
b2 = new Bar();
}
}
Is b1 a valid instantiation?
Yes. Yes it is valid. Every instance of the Foo class will have a field called b1 which has a new Bar instance.