Why do we need public static void main(String args[])
method in Java...?



Why do we need public static void main(String args[]) method in Java...?..

Answer / shadow

We need
• public: The method can be accessed outside the
class / package
• static: You need not have an instance of the class
to access the method
• void: Your application need not return a value, as
the JVM launcher would return the value when it exits
• main(): This is the entry point for the application
If the main() was not static, you would require an instance
of the class in order to execute the method.
....!

$HADOW

Is This Answer Correct ?    14 Yes 0 No

Post New Answer

More Core Java Interview Questions

What do you mean by compiler?

0 Answers  


What are the Memory Allocations available in JavaJava?

1 Answers  


import java.io.*; class Demo { public static void main(String args[]) { File f=new File("1234.msg"); String arr[]=f.list(); System.out.println(arr.length); } }

3 Answers   IBM, Ramco,


Can we make a constructor final?

0 Answers  


Is nan false?

0 Answers  


What is "this" keyword in java? Explain

0 Answers  


What is a function easy definition?

0 Answers  


Is java platform independent?

0 Answers  


What are the differences between string and stringbuffer?

0 Answers  


How will you override default serialization mechanism in java

2 Answers  


Why java doesn’t support multiple inheritances?

0 Answers  


Why do we use public static with the main function in Java?

13 Answers   College School Exams Tests, Infosys,


Categories