System.gc() OR Runtime.getRuntime().gc(). 19. What are two different ways to call garbage collector? If you mark any variable volatile then this variable will be read from main memory rather than CPU cache so each thread will have updated value in the variable. You need to use Comparable or Comparator interface to sort list of custom objects. You have a list of Custom objects? How can you sort them? It is more performance efficient as it is not thread-safe.ĬlassPath is environment variable which java virtual machine (JVM) uses to locate all classes which is used by the program.įor example: jre/lib/rt.jar has all java classes and you also need to include jar files or class file which is being used by program. What is the difference between StringBuffer and StringBuilder? No, You can not declare constructor final. Yes, we can have static method in the interface from Java 8. Can we have static method in the interface? Do you know how to make a class immutable? Can you provide steps for it? You can fin the detailed answer over here. Do you know why String is immutable in java? If you don’t want to make variable serializable, you can make it transient variable. Transient variables are used Serialization. Have you heard about transient variable? When will you use it? Yes, you can have abstract class without having any abstract method. Can we have abstract class without having any abstract method in it? What is the difference between HashMap and HashSet in java? You need to override hashcode and equals method in custom class while putting objects of custom class in HashMap. Which two methods should you override while putting the custom object as Key in HashMap? finalize: This method is called when object is being garbage collected.Ħ.clone : This method is used to clone the object.toString : Provides String representation of the object.notifyAll: Wakes up all threads which is waiting for lock.notify : Wakes up single thread which is waiting for lock.wait : It causes current thread to wait until notify or notifyAll is not called.equals : It compares the object references.hashcode : It returns hash value of the object.Can you list down some of important method from object class? What is the base class for all the classes? You can not override private methods in java as it is visible to that class only. Yes, you can overload main method in java.You can find the detailed answer over here. You can read the detailed answer over here. No, you cannot override static method in java. I have already shared detailed answer over here before, you might find it helpful as well.ġ. This question list will help you to crack java interview. These are the most asked interview questions for freshers(0-3 years experienced). How will you do it?Ĭore In this post, we are going to see Java interview questions for experienced. You have started three threads from main threads.You need to make sure main thread complete last. What is difference between wait and ( “sleep in java”)? What is the difference between ArrayList and LinkedList? How will you decide which one you need to use? Can you differentiate between Checked Exception and Unchecked exception? What is marker interface in java? Can you provide some examples of marker interface? 19. What are two different ways to call garbage collector?.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |