+ 1

What is the difference between default and private in Java please ?

11th Jun 2017, 1:45 PM
Mehdi ABDALLAOUI
Mehdi ABDALLAOUI - avatar
8 Answers
+ 7
private and default are access specifiers for declaring method.. default is user friendly and has access to only classes in package private has minimum access only to the class it self.
12th Jun 2017, 4:58 PM
Ekansh
+ 4
I am putting an short example that would clear you doubts C++ class point2d { private: int x; int y; public: void set (int a, int b) { x=a; y=b; } void plot (){ cout <<x << ", "<<y; } } Java class point2d { private int x; private int y; public void set (int a, int b) { x=a; y=b; } public void plot (){ cout <<x << ", "<<y; } } In C++, private and public are the sections of class definition, whereas, in Java, these are placed before each member of the class.
11th Jun 2017, 1:44 PM
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender)
à€Šà„‡à€”à„‡à€‚à€Šà„à€° à€źà€čà€Ÿà€œà€š (Devender) - avatar
+ 1
Now I see the concept dude ! Break a leg for you !
12th Jun 2017, 5:51 PM
Mehdi ABDALLAOUI
Mehdi ABDALLAOUI - avatar
+ 1
aah yeah sorry , hahah
12th Jun 2017, 5:53 PM
Mehdi ABDALLAOUI
Mehdi ABDALLAOUI - avatar
0
This helped me a lot ! Thanks man !!!
11th Jun 2017, 1:46 PM
Mehdi ABDALLAOUI
Mehdi ABDALLAOUI - avatar
0
aah yeaah I see ! Thank you !
12th Jun 2017, 5:08 PM
Mehdi ABDALLAOUI
Mehdi ABDALLAOUI - avatar