Basic Java Interview Question and Answers
61. | What is a Runtime class? |
---|---|
The runtime class encapsulates the runtime environment. You cannot instantiate a runtime object. However, you can get a reference to the current runtime object by calling the static method Runtime.getRuntime(). Once a reference to the current runtime object is obtained, you can call several methods that control the state and behavior of the JVM. | |
62. | How do the threads communicate with each other in multithreaded programming? |
---|---|
The threads can communicate with each other using the inter process communication mechanism via the wait(), notify(), and notifyAll() methods.
|
|
63. | Can I have multiple main methods in the same class? |
---|---|
No the program fails to compile. The compiler says that the main method is already defined in the class. | |
64. | Can an application have multiple classes having main method? |
---|---|
Yes, it is possible. While starting the application we mention the class name to be run. The JVM will look for the Main method only in the class whose name you have mentioned. Hence there is not conflict amongst the multiple classes having main method. | |