Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Interview-Questions Java - Can a Method Contain another Main Method

Have Programming Question? Ask it here!
 
 
 


Pavani
Java - Can a Method Contain another Main Method
2 Answer(s)      6 years and 6 months ago
Posted in : Java Interview Questions


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


Advertisement
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:
main method
main method  Why is the java main method static
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
Advertisements
main method
main method  What is the argument type of a program's main() method
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
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
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
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
main() method
main() method  Can we define two main() methods having same parameter but with different return type in a program
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
main method
main method  hello, Can I make multiple main methods in the same... can not make multiple main with in the same class program fails to compile. Compiler gives error that the main method is already defined in the class
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
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
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
Main method overloading
Main method overloading  Can we overload main()method
pass method reference in java
pass method reference in java  How to pass method reference in Java
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
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
Using throw in java method
Using throw in java method  using throw with method implies what
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
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
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
Method decleration in java
Method decleration in java  What is the catch or declare rule for method declarations
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
Why we should use string args[] in main method in java?
Why we should use string args[] in main method in java?  we use only string in the main method not any other one.. specify the reason... and tell me... line from the command prompt   In the main method,the String array args
Accessing non-static members through the main method in Java.
Accessing non-static members through the main method in Java.  As an oop rule, a static method can have access only to static variables and static methods. If it is so, an obvious question arises as to how can the main() method
Why is the main method declared static?
java method can be called without having to instantiate in the class that defines...Why is the main method declared static?  Hi, Why is the main method declared static? thanks   Hi, When we declare main() method in any
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 method - Java Beginners
java method  hi friends, Is there any default return type for methods in java?  There is no default return type in java, as a user you have to specify the return type even void
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
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
Java synchronized method
Java synchronized method  What are synchronized methods and synchronized statements
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
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
Java Script location.replace method
Java Script location.replace method  Hi, What does `Print `{<SCRIPT LANGUAGE="JavaScript"> location.replace("} & urlpop & {","BOTTOM") </SCRIPT>} this mean as this is written in an Lotus Script agent and I
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
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
Static method in java - Java Beginners
Static method in java  What are static method in Java  Hi Friend, Please visit the following link: http://www.roseindia.net/java/beginners/howtoaccessstaticmethod.shtml Hope that it will be helpful for you
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
Java: Method Exercises 2
Java: Method Exercises 2 Name: _________________________________ What... another method. Overloaded, */ static void output(int i) { output... September // Remember: // * If a method is overloaded (more than one method
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
 

 

 

DMCA.com