Question: Explain the importance of "static"keyword
Answer: Static keyword ,means only one copy per class if u have a static block or static method it will run first then only other statements like constructor will run . it dosen't need an object to access its method .Though u can access it using object u can access it using class nameso using object is eliminated.
Question:
Explain the importance of "static"keyword
Answer:
Static keyword ,means only one copy per class if u have a static block or static method it will run first then only other statements like constructor will run . it dosen't need an object to access its method .Though u can access it using object u can access it using class nameso using object is eliminated. Source: CoolInterview.com
If the method or variable is declared as static , u don't have to create the object of it . U can access it using classname.methodname() or classname.variablename.
That's one of the reason why we declare main() as static Source: CoolInterview.com