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

 
 


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

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 Pages:
main method
main method  Why is the java main method static
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
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
main method
main method  What is the argument type of a program's main() method
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
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
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
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
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
File.list() method
() method then it is working fine although s2 also prints as "d:/java" ?? help... main(String[] args){ byte b[]=new byte[5000]; System.out.println("enter... as d:/java it is giving NullPointerException. but if I directly write code like
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
Java: Method Exercises 5
by calling another method, */ private static String convertInt(int i... Java NotesMethod Exercises 5 Name: _________________________________ What... static void main(String[] args) { output("A. ", 99); output("B
Java: Method Exercises 1
. ", computeSomething(100, 100)); } /** Displays an integer by calling another method... Java NotesMethod Exercises 1 Name: _________________________________ What...*; class MethodExercises1 { public static void main(String[] args
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
Java Method Return Value
Java Method Return Value   ... a compiler error.  The method that is not declared void must contain... with Example The Tutorial illustrates a code that help you in understanding JAVA method
Method Overriding
; and "Two" and define a same method in both of them. When the main... Method Overriding       Overriding is another useful feature of object-oriented programming technique
main() syntax - Java Beginners
] [import statements] [class declaration] [main() method] For Example: package...main() syntax  Hi, I would like to know the complete structure of the main() in jdk1.5 with sample program. Regards, UsmanAli Shaik,  
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
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
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
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
What is a native method?
,   Hi, This Native mathod is a Java keyword that is used in method declarations to specify that the method will not be implemented in another language... framework, which lets a native method utilize Java objects in the same way that Java
String replaceFirst() Method
. We are going to use replaceFirst() method of String class in Java. The description of the code is given below for the usage of the method. Description... String replaceFirst() 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
how to use toString method? - Java Beginners
how to use toString method?  i'm a new student, and learn with java... a method toString() that prints the manager?s name, department and salary. Make another... named carAllowanceAmount. Supply the toString() method for Director that prints all
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
Dynamic method dispatch
polymorphism is achieved  in java. Let suppose a class A contain a method...Dynamic method dispatch Dynamic dispatch is a process of selecting, which methods to call at run-time. It is a mechanism by which a call to overridden method
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
Insert an array list of objects with addAll(ArrayList) method
Insert an array list of objects with addAll(ArrayList) method In this section you will learn to insert an array list of objects to another list...) method in more detail.   Create a class "addAll"
Method Signatures
and method definitions. To define a method in java we need to abide by the certain java syntax known as the method signature to create a method within a class... Return Type is void Method Name is main List of Arguments with comma separation
Use of equals() method of  FloatBuffer class in java.
Use of equals() method of  FloatBuffer class in java.  In this tutorial, we will check  float buffer is equal  to another buffer... or not to another object. If another buffer is not float buffer method returns
Use of equals() method of IntBuffer class in java.
Use of equals() method of IntBuffer class in java.  In this tutorial, we... obj) The equals() method tells this buffer is equals or not to another object. If another buffer is not int buffer method returns false
Use of equals() method of LongBuffer class in java.
Use of equals() method of LongBuffer class in java.  In this tutorial, we... obj) The equals() method tells this buffer is equals or not to another object. If another buffer is not long buffer method returns false
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... RemoveAllElement { public static void main(String[] arg) { HashSet obHashSet = new
java Method Error - Java Beginners
java Method Error  class mathoperation { static int add(int...-n); } } class mathdemo { public static void main(String args... mathdemo.java:7: missing method body, or declare abstract static int
Use of equals() method of ByteBuffer class in java.
Use of equals() method of ByteBuffer class in java.  In this tutorial, we will check this ByteBuffer is equal to another object...(object obj) The equals() method tells this buffer is equals or not to another
Another distance conversion - Java Beginners
Another distance conversion  Write an application that reads... a method for each conversion ? toKilometres(), toFeet(), and toInches...; return inchValue; } public static void main(String args
Example of Hashset size() method in java.
Example of Hashset size() method in java. The size() is a method of HashSet class. It is used to calculte the size of HashSet. The size of method... class SizeOfHashSet { public static void main(String[] arg) { HashSet
Use of isReadOnly() method in java.
Use of isReadOnly() method in java. In this tutorial, we will see how to use of isReadOnly method in java. IntBuffer API : The java.nio.IntBuffer class... type Method Description static IntBuffer allocate
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...() method executing..."); } public static void main(String args[]) throws
Input / Output in Easiest Method in Java
with the easiest method in Java?   Hi Friend, Try the following code: import java.util.*; public class ReadFromConsole { public static void main(String[] args...Input / Output in Easiest Method in Java  How to input from keyboard
Java draw triangle draw method?
Java draw triangle draw method?  hi how would i construct the draw method for an triangle using the 'public void draw (graphics g ) method? im...; Here is an example that draws a triangle using drawPolygon method. import
Java hashmap clear() method example.
Java hashmap clear() method example. This tutorial is based on clear() method of java HashMap class. It removes all values from HashMap. Code: ... java.util.HashMap; public class HashMapRemoveAll{ public static void main(String
Example of toArray() method of hashset in java.
Example of toArray() method of hashset in java. The toArray() is a method of HashSet in java. It is used to create array of object. It is also used...; HashSetToArray .java package net.roseindia; import java.util.HashSet