Basic Java Interview Question and Answers

53. What modifiers may be used with top level class?
  Public, abstract and final can be used for top level class.
 
Your Name Your Email-ID
Your Answer
54. What are the problems faced by Java programmers who don't use layout managers?
  Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system.
 
Your Name Your Email-ID
Your Answer
55. How can you copy one array in to a different array?
  System.arraycopy(myOldArray, 0, myNewArray, 0, length);
 
Your Name Your Email-ID
Your Answer
56. Why are Single threaded systems not used in Java?
 
  • Single threaded systems use an approach called an event loop with pooling. In this model, a single thread of control runs in an infinite loop, polling a single event queue to decide what to do next.
  • Once this polling mechanism returns with, say a signal that a network file is ready to be read, then the event loop dispatches control to the appropriate event handler. Until this event handler returns, nothing else can happen in the system. This wastes CPU time. It can also result in one part of a program dominating the system and preventing other events from being processed.
  • In general, in a single-threaded environment, with a thread blocks because it is waiting for some resource, the entire program stops running.
  • The benefit of multithreading is that the main loop/polling mechanism is eliminated. One thread can pause without stopping other parts of the program.
 
Your Name Your Email-ID
Your Answer