31. What is OutOfMemoryError in java? How to handle it?
This error occurs when JVM is not able to allocate memory for an object.
Temporary Solution:
Increase the heap size by using the following command.
-Xms1024m -Xmx1024m
Permanent Solution:
Find the memory leaks in the code and ensure the memory is used effectively.
32. What is Final, Finally and Finalize?
Final is a keyword. Variable declared final cannot be modified. Method declared final cannot be overridden. Class declared final cannot be inherited.
Finally is a block. Finally is executed always after the catch block.
Finalize method is used for garbage collection by java.
33. Explain Thread?
Threads are used when multiple task need to be performed on the single program.
34. What are different ways of creating thread?
• Extend thread class and override run() method
• Implement runnable interface
35. What are the different states in thread’s lifecycle?
• New
• Runnable
• Running
• Waiting
• Blocked
• Sleeping
• Dead
Previous - Next
No comments:
Post a Comment