+ 1

What do these terms mean?

I've always had trouble understanding these terms, can you simplify them in your own words?: Public, static, void, private

4th Dec 2019, 10:15 AM
Jason Wade
Jason Wade - avatar
3 ответов
+ 3
Public It is a access specifier. It specifies the limit of use of any variables, class, methods etc. If you use public as a specifier than you can access it from anywhere inside your package. Ex: public class A static It is keyword that is used to make a variable, object, method etc as a class oriented. Means there values or property remain same for all the objects. If you have 2 objects ob and obj builded from a class having a class variable(static int a;). Than if you change its value in one object, it will get changed into the other also. Static is also used to call a method without creating object of some class. void Every method return something. Like int sum(int a, int b) return (a+b) ; It returns a int value. But what if you don't want that a functions should return anything. In that case use void keyword. Ex void sum(int a, int b) //body private It is also a type of access specifier. If you use this specifer than you can access that thing(maybe variable, methods etc) inside the class o
4th Dec 2019, 10:28 AM
Nitin Tiwari
Nitin Tiwari - avatar
+ 2
Continue: only. You cannot use that code from outside of that class. You will understand better about access specifier and static keyword when you will study about object and classes.
4th Dec 2019, 10:30 AM
Nitin Tiwari
Nitin Tiwari - avatar
+ 1
A small change, the public access modifier can be accessed from any package within a project provided that you have imported that package.
4th Dec 2019, 10:53 AM
Avinesh
Avinesh - avatar