why java main method is given as static method?
Answers were Sorted based on User's Feedback
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 |
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 |
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What is the difference between array and arraylist? what is the difference between arraylist and linkedlist?
what is the swingutilities.invokelater(runnable) method for? : Java thread
What is an immutable class?
What is the default size of set in java?
Which sorting is best in java?
Is singleton thread safe in java?
What is a buffer in java?
What is the format of Inner Class after it compiled?
Can we have more than one package statement in source file ?
Why is sizeof not a function?
How do listeners work?