0
Can you please explain easily about private public in class and also about constructors in classes with examples ?
8 Respuestas
+ 1
If java,then public ,private and protected are access modifiers.If the method or variable is made public then it can be used anywhere.
If private,then it can be accessed by only that class.If protected ,then it can be used by the inherited class only.
Constructed are used as method to initialize the variable on being run .
0
A public variable/function can be accessed in other classes while a private one is only accessible in the class it was defined.
A constructor is a fuction inside of a class that will be executed when an instance of a class is created.
If you want examples you have to put the programing language in the tags so i know in which languge to write the examples
0
C++
0
I will send you a commented code wait a bit
0
Ok
0
The output will be text1text2 if you uncomment the line
instance.Private() it will give an error
0
Mention related to which programming language.