Home  >  Forum  >  Core Java
Post New Query

Why we write the Static keyword in Java program?


joined on
October 10,2013
Asked on September 24,2014
while writing the code of java we use static keyword,
example 

class add{
       public static void main(String [] args)
            {
                 int a=3, b=4;
                 int c= a+b;
             }
}
anyone please tell me why we use static?
joined on
March 15,2013
Replied on October 08,2014

To start the main method use use Static keyword... its may be woks a constructor.
joined on
September 16,2014
Replied on October 08,2014

1)public:Public is access specifier means anyone can access/invoke it such as JVM(Java Virtual Machine.
2).static:Static keyword allows main() to be called before an object of the class has been created.
This is neccesary because main() is called by the JVM before any objects are made.Since it is static so directly invoked from class.

Write Answer









Copyright ©2017 concretepage.com, all rights reserved |Privacy Policy | Contact Us