why java main method is given as static method?

Answers were Sorted based on User's Feedback



why java main method is given as static method?..

Answer / saravanan.v

Java is a object oriented language.So even main method also should be written inside a class name main class.So main method should be called WITHOUT CREATING OBJECT for main class.For this purpose, it is declared as static.

Is This Answer Correct ?    6 Yes 0 No

why java main method is given as static method?..

Answer / chaithanya

main method is called by JVM.without creating the object we are calling main.that's what it is declared Static.
static nothing but without creating the object,we can call that method

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Core Java Interview Questions

How can u create the Object of class Without using "New" opertor?

3 Answers   IBM, TCS,


What will happen inside init() in servlet. my interviewer asked servlet lifecycle. i said "once servlet is loaded in to memory init() will be called which performs servlet initialization " . Again interview asked what values will be initialized . what is difference between init() and init(ServletConfig config).

2 Answers   Infinite Computer Solutions, TCS,


what is run time polymorphism

4 Answers  


Can you write a java class that could be used both as an applet as well as an application?

1 Answers  


What are access modifiers?

1 Answers   Infosys,


Can a class be final?

1 Answers  


they asked class A{} class B{} class c{} all the three class saved as a single file,there is no main method in the file and anothe class M.java class m { psvm(String args[]) { // here the parent class can access } }

2 Answers   DNS, IPSR Solutions,


How many ways can we create the string object?

1 Answers  


What is a jagged array in java?

1 Answers  


how can u create the object with out new operator

2 Answers  


What is race condition ?? (Threading concept) TCS 2 sept10

3 Answers   SparkTG, TCS,


explain Anonynous inner class?

6 Answers   TCS,


Categories