What does the key word 'public' mean? The method belongs to the class and gets called on the class when used. The method can only be used inside the class in which it is declared. The method can be used inside or outside the class in which it is declared. The method will not return anything. in java
OOPs
In today's technology-driven world, computer programming skills are in high demand. The object-oriented programming (OOP) approach is very much useful while designing and maintaining software programs. Object-oriented programming (OOP) is a basic programming paradigm that almost every developer has used at some stage in their career.
Constructor
The easiest way to think of a constructor in object-oriented programming (OOP) languages is:
What does the key word 'public' mean?
The method belongs to the class and gets called on the class when used. |
||
The method can only be used inside the class in which it is declared. |
||
The method can be used inside or outside the class in which it is declared. |
||
The method will not return anything. in java |
'public' keyword-
A 'public' keyword is an access modifier.
It is used for classes, methods, constructors.
It is non-restricted type of access modifier.
So, it is accessible everywhere.
We can access public inside or outside the class.
If a class , method etc. declared public then it can be accessed from any other class.
Example of 'public' keyword-
public class Employee //public class name
{
public String name; //public variable 'name'
public void work() // public method 'work'
{
}
}
In this example, there is a public class which has a public variable and public method.
Step by step
Solved in 3 steps