Java - Can a Method Contain another Main Method

Java - Can a Method Contain another Main Method

Do you think that we can write a Method that contains another Main Method of the Class?

View Answers

March 12, 2008 at 9:57 PM

Can a main method can contain another main method?
If it can contain what will happen?
A main method can have another main method and it will work like method overloading by taking different arguments of different type

April 12, 2008 at 7:04 PM

Hi friend,

A Java class contains a constructor method and finalize method. A Java class that is abstract does not contain a constructor. The constructor is called first, unless the class is being started from main. The Java constructor name is the same as the class name and is allowed multiple signatures. The finalize method is called when the object is destroyed or garbage collected. If the Java source code does not contain the constructor or finalize methods the Java compiler will use the default constructor and finilize method for you.

-----------------------

read for more information,

http://www.roseindia.net/java/









Related Tutorials/Questions & Answers:
java sleep in main method
java sleep in main method  Hi, How to write Java program for sleeping in the main method? I want Java program to have sleep in main method. Try to share me the code examples. Thanks
java sleep in main method
java sleep in main method  Hi, How to write Java program for sleeping in the main method? I want Java program to have sleep in main method. Try to share me the code examples. Thanks
Advertisements
main method
main method  Why is the java main method static
main method
main method  What is the argument type of a program's main() method
When is java main method called?
When is java main method called?  When is java main method called? Please explain the main method in Java with the help of code.   In a java class, main(..) method is the first method called by java environment when
What is the arguement of main method?
What is the arguement of main method?  hi, What is the arguement of main method? thanks,   Hi, For main() method accepts only an array of String object as arguement. For moe details on http://www.roseindia.net/java
What is the return type of the main method?
What is the return type of the main method?  hi, What is the return type of the main method? thanks   Hi, In the java programming the Main() method doesn't return anything hence declared void. In Java, you need
What if the main() method is declared as private?
What if the main() method is declared as private?  Hi, What if the main() method is declared as private? Thanks   Hi, I have found some reference site for java programming coding for Main() method is declared
Should a main method be compulsorily declared in all java classes?
Should a main method be compulsorily declared in all java classes?  hi, Should a main method be compulsorily declared in all java classes? thanks... in all java classes. Where as the main method we should be defined only if the source
How to found which class or method contain specific annotation?
How to found which class or method contain specific annotation?  ... will be appreciated I am using core java reflection and annotations. Original Scenario... categories of testcase. i want to found method or class according to category
Is main method compulsory in Java?
Is main method compulsory in Java?  Hi, Can we have a executable class in Java without a main method? I am going to write simple Java program and there is main method. Is main method compulsory in Java? Thanks   Hi
What is the first argument of the String array in main() method?
What is the first argument of the String array in main() method?  Hi, What is the first argument of the String array in main() method? Thanks... of the String array in main() method
main() method
main() method  Can we define two main() methods having same parameter but with different return type in a program
main method
main method  hello, Can I make multiple main methods in the same...; hello No we can not make multiple main with in the same class program fails to compile. Compiler gives error that the main method is already defined
main method
in paranthesis denote?   Hi Friend, public-It indicates that the main() method can be called by any object. static-It indicates that the main() method is a class method. void- It indicates that the main() method has no return value
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code...() { initComponents(); } /** * This method is called from within
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code...() { initComponents(); } /** * This method is called from within
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code...() { initComponents(); } /** * This method is called from within
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code...() { initComponents(); } /** * This method is called from within
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code...() { initComponents(); } /** * This method is called from within
Till Slip Program Error Free - No Main Method
Till Slip Program Error Free - No Main Method  Hi there i am a java... that the program recquires a main() method in order to be runned - here is the following code...() { initComponents(); } /** * This method is called from within
pass method reference in java
pass method reference in java  How to pass method reference in Java
method inside the method??
method inside the method??  can't we declare a method inside a method in java?? for eg: public class One { public static void main(String[] args) { One obj=new One(); One.add(); private static void add
Using throw in java method
Using throw in java method  using throw with method implies what
class method in java
class method in java  How to write a class method in Java?   You must read Java - Class, Object and Methods in Java
how to open one Jframe from main method call
how to open one Jframe from main method call  I have downloaded... the main() method, when i run this Engine.java class game starts running...(containing main() method) Snake.java GameBoard.java PlayGame.java
Method decleration in java
Method decleration in java  What is the catch or declare rule for method declarations
method overloading - Java Beginners
method overloading   Write a program to demonstrate the method... }  Hi Friend, In Java, the methods having the same name within... is referred to as Method Overloading. In the given example, we have defined
try catch method in java
try catch method in java  try catch method in java - when and how should i use the try and catch method in Java ?   Please visit the following links: http://www.roseindia.net/help/java/t/java-try.shtml http
Static Method in Java
Static Method in Java  Is Overriding Static methods possible in java? If Yes, How
Generic Method - Java Beginners
Generic Method  I want simple java program for Generic Method with explanation
Class and method question, Java?
Class and method question, Java?  Consider a Java class that you... Prompt string** and the following method: getValue displays the prompt and reads..., the method should display an error message and ask the user for a new value
java method - Java Beginners
java method  Plz help me on toString() in java  Hi Friend, The Object class provides the method toString() that returns the string..., the toString() method of the object is automatically called. Thanks
Java Method with arrays
Java Method with arrays  My assignment is to write a java method..., write a program to test your method. my main method code is : public class...]; currentSmallestIndex = i; } } return currentSmallestIndex; } //main method
method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding
method overriding in java
method overriding in java  program to compute area of square,rectangle,triangle,circle and volume of sphere,cylinder and perimeter of a cube using method overriding
calling method - Java Beginners
static void main(String args[ ]){ } } I Want to call method fo1...calling method   class A{ public void fo(){ class B..."); } } } class D{ public static void main(String args[ ]){ A a=new A(); a.fo
Java Thread : yield() method
Java Thread : yield() method In this section we are going to describe yield() method with example in java thread. yield() Method: When you want to stop current thread and switch the CPU availability to another thread, call yield
Main method overloading
Main method overloading  Can we overload main()method
Finalize method in Java - Java Beginners
Finalize method in Java  Hi, What is the use of Finalize method in Java? Give me few example of Finalize method. Thanks   Hi Friend, Java uses finalize() method for Garbage collection. Example: import
Polymorphism : Method Overriding
In this tutorial you will learn another concept of polymorphism that is method overriding
Java method Overriding
Java method Overriding       Below example illustrates method Overriding in java. Method overriding in java means a subclass method overriding a super class method. Superclass
Java Thread : run() method
Java Thread : run() method In this section we are going to describe run() method with example in java thread. Thread run() : All the execution code...() { System.out.println("run() method executing..."); } public static void main(String
what is ment by method signature in java.......
what is ment by method signature in java.......  what is ment by method signature in java.......   Hi Friend, The signature of a method is the combination of the method's name along with the number and types
Example of Hashset iterator method in java.
Example of Hashset iterator method in java. In this exmple of HashSet class,  you will see the use of iterator() method. It is used for traversing all... static void main(String[] arg) { (adsbygoogle = window.adsbygoogle
Final method in java
Final method in java In this section we will learn about Final method in java. Final  keyword in java is used with class, variable and methods. If final is used with method that method will not be overridden in subclass, if final
Destroy method in java - Java Beginners
Destroy method in java  Hi, What is the implementation of destroy method in java.. is it native or java code? Thanks   Hi Friend, This method is not implemented. Thanks
How to use charAt() method in Java?
How to use charAt() method in Java?  Hi, what is the correct way of using chatAt() method in Java? Thanks   The charAt() method in Java... at charAt() Method In Java. Thanks
Static Method in java with realtime Example
Static Method in java with realtime Example  could you please make me clear with Static Method in java with real-time Example
String length without using length() method in java
String length without using length() method in java  How to count length of string without using length() method in java?   Here is Example: package RoseIndia; public class ArrayString { public static void main

Ads