UrbanPro

Learn Java Training from the Best Tutors

  • Affordable fees
  • 1-1 or Group class
  • Flexible Timings
  • Verified Tutors

Search in

Why do we use â??public static void mainâ?? only in Java?

Asked by Last Modified  

Follow 5
Answer

Please enter your answer

This is neccesary because main() is called by the JVM before any objects are made. Since it is static it can be directly invoked the class. Similarly, we use staticsometime for user defined methods so that we need not to make objects. voidindicates that the main() method being declared does not return...
read more

This is neccesary because main() is called by the JVM before any objects are made. Since it is static it can be directly invoked the class. Similarly, we use staticsometime for user defined methods so that we need not to make objects. voidindicates that the main() method being declared does not return a value.

read less
Comments

IT Professional Trainer with 10+ years of experience in IT industry

public static void main() main() is the starting point of any java program and your code write inside it. Without it you can not execute console progem in java
Comments

Algomitra Java Tutor

Every computer program needs a starting point of execution and the static main function is the starting point of execution in Java language. Now it was a choice of the language designers of Java to make it that way. But there is a reason to make it static because if it is not static then JVM has to create...
read more

Every computer program needs a starting point of execution and the static main function is the starting point of execution in Java language. Now it was a choice of the language designers of Java to make it that way. But there is a reason to make it static because if it is not static then JVM has to create an instance of the class where the main method is then it has to call the main method, which is an extra overhead in terms of performance.

read less
Comments

Technical Trainer IT With Overall Experience of 10+ Years

Whenever we use static keyword before any function it means that the function can be invoked when required without using object. And main() is the function that starts the execution of program. So the function to be invoked by JVM it has to be public. It has to be static so that it can be invoked without...
read more

Whenever we use static keyword before any function it means that the function can be invoked when required without using object. And main() is the function that starts the execution  of program. So the function to be invoked by JVM it has to be public. It has to be static so that it can be invoked without creating any object. We can use any other return type like int instead of void if we want main() to return any value. 

read less
Comments

View 2 more Answers

Related Questions

What is 'this' in Java?
this is a keyword in Java. Works as a reference to current object whose constructor is being invoked
SEED Infotech Ltd
Is Java a compiler or Interpreter?
Java is a programming language and computing platform first released by Sun Microsystems in 1995. A Java compiler is a compiler for the Java programming language. A JVM interprets bytecode and...
Dr Rakesh
What is difference between C language and Java language?
C is more procedure-oriented while JAVA is data-oriented. Java is an Interpreted language while C is a compiled language. C uses the top-down {sharp & smooth} approach while JAVA uses the bottom-up...
Poonam
0 0
5
Which is the best IDE to write Java code?
Eclipse and intellige are the best IDE to write Java Code.
Akash

Now ask question in any of the 1000+ Categories, and get Answers from Tutors and Trainers on UrbanPro.com

Ask a Question

Related Lessons

Java : Compile-time Versus Runtime optimization
While designing and development, one should think in terms of compile-time and run-time.It helps in understanding language basics in a better way.Let's understand this with a question below : What...
S

doWhile example in Java
public class doWhilePracticleEx { public void test() { } public static void main(String args) { String q1 = "Who is PM of India?"; String a1 = "Sonia Gandhi"; String a2 = "Rahul Gandhi"; String a3...
S

Sarthak C.

0 0
0

TestNG Annotations and its sequence
public class TestNGAnnotations { @BeforeMethod public void beforeM() { System.out.println("Before Method"); } @AfterMethod public void afterMethod() { System.out.println("After Method"); } @BeforeClass...
S

Sarthak C.

0 0
0

Interview Tip : Q1) Why Strings are immutable in java ? What happen if it was mutable in java?
As we all know that Strings in java are immutabe in nature, now the question comes why the creator made it immutable in nature, although this field used maximum in any java program. The answer to this...

Crux Of The Basic Interview Question Asked Around It Professionals
Question: Explain PSVM() in Java. Answer: This question is asked from a differnet persctive. Person asking this question is looking for deep java concepts. If answer in your mind is something like...

Recommended Articles

Java is the most commonly used popular programming language for the creation of web applications and platform today. Integrated Cloud Applications and Platform Services Oracle says, “Java developers worldwide has over 9 million and runs approximately 3 billion mobile phones”.  Right from its first implication as java 1.0...

Read full article >

Java is the most famous programming language till date. 20 years is a big time for any programming language to survive and gain strength. Java has been proved to be one of the most reliable programming languages for networked computers. source:techcentral.com Java was developed to pertain over the Internet. Over...

Read full article >

Designed in a flexible and user-friendly demeanor, Java is the most commonly used programming language for the creation of web applications and platform. It allows developers to “write once, run anywhere” (WORA). It is general-purpose, a high-level programming language developed by Sun Microsystem. Initially known as an...

Read full article >

In the domain of Information Technology, there is always a lot to learn and implement. However, some technologies have a relatively higher demand than the rest of the others. So here are some popular IT courses for the present and upcoming future: Cloud Computing Cloud Computing is a computing technique which is used...

Read full article >

Looking for Java Training Classes?

Learn from the Best Tutors on UrbanPro

Are you a Tutor or Training Institute?

Join UrbanPro Today to find students near you
X

Looking for Java Training Classes?

The best tutors for Java Training Classes are on UrbanPro

  • Select the best Tutor
  • Book & Attend a Free Demo
  • Pay and start Learning

Learn Java Training with the Best Tutors

The best Tutors for Java Training Classes are on UrbanPro

This website uses cookies

We use cookies to improve user experience. Choose what cookies you allow us to use. You can read more about our Cookie Policy in our Privacy Policy

Accept All
Decline All

UrbanPro.com is India's largest network of most trusted tutors and institutes. Over 55 lakh students rely on UrbanPro.com, to fulfill their learning requirements across 1,000+ categories. Using UrbanPro.com, parents, and students can compare multiple Tutors and Institutes and choose the one that best suits their requirements. More than 7.5 lakh verified Tutors and Institutes are helping millions of students every day and growing their tutoring business on UrbanPro.com. Whether you are looking for a tutor to learn mathematics, a German language trainer to brush up your German language skills or an institute to upgrade your IT skills, we have got the best selection of Tutors and Training Institutes for you. Read more