Q:

acess modifiers ,visual basic, object´s scope versus classes´s scope

i am a beginner in vb.net (self-taught).i try to understand the difference of object´s scope  to classes´s scope. how a object  is private and your class is public?example:
 Public Class car 'create a class carro
    private car_name As String
   End Class

Public Class Form1 'create two objects of the class carro
    Public obj_1 As New carro
    Private Obj_2 As New carro
end class

'what is the difference between objcar_1 and objcar_2 in terms of access modifier?how a public class can generated a private object ?any book recommendation about this question ? thanks in advance. (greetings from Brazil )
enter image description here

A:

In the context of a class, Public means that that class can be accessed from outside your assembly (.NET EXE or DLL), while Friend means that it can only be access from inside.  That makes little difference in an EXE but is important in a DLL.  Anyone referencing your DLL can access all the Public classes but not the Friend classes.  That means that you can define a class that is intended only as a helper within your own project and declare it Friend and then no one else will be able to reference your DLL and access that class.
Private only applies to a class if it is declared inside another class.  That is something you should rarely do but it makes sense if the inner class is only ever used in situations that involve the outer class.  Public and Friend mean exactly the same for nested classes as they do for others but Private means that the nested class can only be used inside that one outer class.  The nested class effectively does not exist as far as any code outside the outer class in concerned, even if the outer class is declared Public.
Fields and other members (properties, methods, events) follow the same rules as nested class.  If they are Public then any code that can access the class can access the member too.  If they are declared Friend then they cannot be accessed outside the assembly they are declared in, even if the class they are a member of is declared Public.  If they are Private then they can only be accessed inside the class they are declared in, even if the class is Public.
Basically, the access modifier on a class determines the access level for that type and the maximum access level for its members.  Any member declared with a higher access level than the type it's declared will effectively take on the access level of that type, while those with lower access levels will act accordingly.

