Questions tagged as 'private'

4
answers

Is "private" in classes in C # optional?

What is the difference between private string abc = ""; and string abc = ""; ? Is there a difference or is it just the writing that changes? I did a test with and without the private and saw no difference, it worked equally. E...
asked by 12.09.2017 / 22:24
5
answers

Difference between private and final methods

Studying final methods and classes in the book "Programming in Java 6 ed." of Deitel I came across the following proposition:    The methods declared private are implicitly final, because it is impossible to overwrite them in a subclass (alt...
asked by 30.11.2015 / 12:22
1
answer

Why use private?

I'm learning variables public and private . If I create all the program code, what is the need to create a private variable? Being that enough I do not program a code that accesses the same one of another class. While r...
asked by 14.11.2016 / 21:26
1
answer

Access modifier property C #

I noticed that it is possible to sign the access mode of a property as private: public string Codigo { get; private set; } Or just ignore it: public string Codigo { get; } Is there a difference or some scenario where one of these signa...
asked by 10.04.2016 / 17:29
1
answer

What happens in real life in a developer environment if the programmer does not encapsulate an attribute? [duplicate]

The programmer John went there and created a Cliente class and the public double saldo attribute and the Sacar() public method as well. What is the problem with leaving the double saldo attribute, what would be t...
asked by 12.05.2017 / 23:36
2
answers

Property with private set

Is there a difference between declaring the set private or just omit it? public int UmaPropriedade {get; private set;} public int OutraPropriedade {get;} Are the two lines of code equivalent?     
asked by 03.02.2018 / 12:14
1
answer

Private class in C #

I have a class Pessoa.cs private , but I can call it in another class, for example I created a class called Parametro.cs ; I can instantiate the class private Pessoa without the slightest problem. Should not priva...
asked by 01.06.2018 / 13:16
4
answers

Private or protected class in PHP

Is it possible to create a private or protected class in PHP in order to allow access to its variables and functions only to other specific classes? Application: I have a class where I create a connection to the database and wanted to allow...
asked by 22.03.2018 / 20:59
0
answers

Accessing private property with decorator in typescript

In Typescript, is it possible to access a private property by the decorator? An example of the code I've already done class A { @dec private _teste: string = 'teste' constructor(){} public get teste() { return this._teste...
asked by 02.01.2019 / 23:31
1
answer

Why use private?

I'm learning variables public and private . If I create all the program code, what is the need to create a private variable? Being that enough I do not program a code that accesses the same one of another class. While r...
asked by 14.11.2016 / 21:26