In the above program,assigning �s� to �msg� before knowing the member variable �msg� declaration.How come the constructor inside msg=s is working without showing any compile error?when executing Line1,we didn�t know what type msg is?
Question is not which come first? Important thnig is the flow of controlat runtime.
When you call constructor, first msg is assigned default value. Since its type is String, it is assigned to null. Then after that constructor will explicitly set msg to s. So at that time, runtime system knows the type of msg.