ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
Why do we use public static with the main function in Java?
 Question Submitted By :: Nauzer Kaifi
I also faced this Question!!     Rank Answer Posted By  
 
  Re: Why do we use public static with the main function in Java?
Answer
# 1
public is used so that it can be called easily from outside 
the scope of function.Static is used so that it can be 
easily called without using its object.
 
Is This Answer Correct ?    17 Yes 4 No
Sai
 
  Re: Why do we use public static with the main function in Java?
Answer
# 2
public means we are allowing the main method to be accessed
any where in the application.and is declared static because
jvm will look for the static one's once it completes the
loading the class.
 
Is This Answer Correct ?    5 Yes 3 No
Ravikiran(aptech Mumbai)
 
 
 
  Re: Why do we use public static with the main function in Java?
Answer
# 3
As we know public means we can access the method from 
anywhere.Coming to static:- main() is a static method 
therefore it implies that there is no need of creating 
Object for that particular class to call this method.So 
that when ever u run the program the Jvm will search for 
main() in the class even there r no class objects created 
for this class.
 
Is This Answer Correct ?    5 Yes 3 No
Rana
 
  Re: Why do we use public static with the main function in Java?
Answer
# 4
public means-accessable from anywhere
static means-the point ,from where compilar can start its 
compilation without object.
 
Is This Answer Correct ?    4 Yes 4 No
Abhijit
 
  Re: Why do we use public static with the main function in Java?
Answer
# 5
In the main function generally we are using
public static void main(String args[])
that means public is used for call method without being the
member of the class.
and static is used for to call method directly with no need
of the object creation.
 
Is This Answer Correct ?    1 Yes 3 No
Deepak Divvela
 
  Re: Why do we use public static with the main function in Java?
Answer
# 6
As we know public means we can access the method from 
anywhere. in a java we want call method by using class 
object. But main() is also method .that main() is there one 
class but jVM execute program trough main() method with out 
creating object main() method call thats way we use public 
static the main function
thanks& regargs
RAMESH
 
Is This Answer Correct ?    2 Yes 1 No
Rameshreddy.k
 
  Re: Why do we use public static with the main function in Java?
Answer
# 7
if we don't use public in main method jvm is looked for main
method but does not found.so run time error will occurred
"main() method must be declared as public". why its static
means in java we can execute methods with object.if we use
static it will execute without object.
 
Is This Answer Correct ?    1 Yes 0 No
Bheemrao
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
What is "Java Native Interface" and how to use it? IBM1
what is the difference b/w PUT and POST method to send data to the server Mind-Tree2
When garbage collector invokes object?s finalize() method?  3
What is file class and what is its purpose?  1
How GC (Garbage Collector) knows the objects reference is unused.Whether GC removes the unused object Parmanently or it maintains something.  2
How many bits are allocated to represent character of character sets - Unicode, ASCII, UTF-16, UTF-8?  1
What is static binding and where it occurs?  2
How are this and super used?  6
Howmany classes that package java.applet.* contains? TCS1
I have a Arraylist object, it has duplecate values also. Now question is i want delete duplecate data in that objet with out using Set? Aricent5
What is the use of an interface?  3
What is OOP? BMC2
whats string ? HCL8
What is casting?  3
Diff between C++ and java? TCS8
In Serialization, whether you will use Static variables? HCL2
which one is performance wise advantageious from List,Set,Map?  5
what is difference between method overloading & method overridding with example? IBM2
What modifiers are used with a top level class?  2
We have two methods to create methods the threads. 1. Implementing runnable interface 2. Extending to thread class and overriding run method. Among these two which one is better and why? Please explain me in detail.  2
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com