Qus:    What is the purpose of static methods and variables?
Feb 09, 2021 17:17 Java 1 Answers Views: 1181 vanceuk20
Prev Next
Answers (1)
IMMEDIATE EDGE Feb 10, 2021 14:02
Answer:   The methods or variables defined as static are shared among all the objects of the class. The static is the part of the class and not of the object. The static variables are stored in the class area, and we do not need to create the object to access such variables. Therefore, static is used in the case, where we need to define variables or methods which are common to all the objects of the class.
For example, In the class simulating the collection of the students in a college, the name of the college is the common attribute to all the students. Therefore, the college name will be defined as static.

Post Your Answer
Guest User

Not sure what solution is right for you?

Choose the right one for you.
Get the help of the experts and find a solution that best suits your needs.


Let`s Connect