officemili.blogg.se

Inheritance in java interview questions
Inheritance in java interview questions







inheritance in java interview questions

Q18 Explain the lifecycle of a Thread in java? You can find all the differences between the wait and sleep method here. Q17 What is the difference between wait and sleep methods in Java? Q16 How ConcurrentHashMap works internally in Java?Ī detailed explanation of ConcurrentHashMap internal working can be found here. The detailed answer to the difference between HashMap and Hashtable can be found here. Q15 What is the difference between HashMap and Hashtable? Q14 What is the difference between HashMap and ConcurrentHashMap?Ī detailed explanation of the difference between HashMap and ConcurrentHashMap can be found here. The detailed answer to the difference between fail-fast and fail-safe can be found here. Q13 What is the difference between fail-safe iterators and fail-fast iterators? Find the detailed answer to How HashMap works internally in Java here. This is one of the most important questions that every java developer must know. Q12 How HashMap works internally in Java? The detailed answer to the difference between LinkedList and ArrayList can be found here. Q11 What is the difference between LinkedList and ArrayList in Java? The detailed answer to the difference between Array and ArrayList can be found here. Q10 What is the difference between Array and ArrayList? Which is better?

inheritance in java interview questions inheritance in java interview questions

When you run System.exit(0) in the try or catch block, then finally block does not execute.

inheritance in java interview questions

No, there is one scenario where the finally block does not execute. Q9 Does finally block always execute in Java? It ensures that each resource is closed at the end of the statement. A resource is an object that must be closed after the program is finished with it. Q8 What is the try with resources statement in Java?Īccording to Oracle docs, try-with-resources is a try statement that declares one or more resources. Q7 What is the difference between throw and throws in Java? You can find a detailed explanation here. Q6 What is the difference between Checked and Unchecked Exception in Java? It is a mechanism by which a call to an overridden method is resolved at run time. At runtime, it is the type of object being referred to not the type reference of the variable that decides which version of an overridden method needs to be executed. Q5 What is the Dynamic method dispatch in Java?ĭynamic method dispatch is also known as Run time polymorphism. If a child class defines a static method with the same signature as a static method in the parent class, then the method in the child class hides the method in the parent class. It concludes the method called is determined at compile time. Also, for class-level methods i.e static methods, the type reference decides which method is called not the object being referred. In method overriding, it is the object that decides which method is to be called.ī. The static method belongs to the class level, not the object level. No, it is not possible to override the static method in Java. Q4 Is it possible to override the static method in Java? Method Overriding is used to provide the specific implementation of the method. Method Overloading is used to increase the readability of the program. Q3 What is the difference between Method Overriding and Method Overloading in Java? It contains static constants and abstract methods. In simple words, Interface is a blueprint of the class. finalize(): this method is invoked by garbage collector just before the object is garbage collected. notifyAll(): wakes up all the threads, waiting for this object's monitor. notify(): wakes up the single thread waiting for this object's monitor. wait(): causes the current method to wait until another thread calls notify() or notifyAll() method.į. toString(): this method returns the String representation of the given object.Į. hashCode(): this method returns the hash value of the object.ĭ. equals(): this method is used to check whether objects are equal.Ĭ. clone(): this method is used to create a clone of the objectī. Q1 List down methods present in the Object class?īelow are the important methods present in the Object class:Ī. Java Interview Questions for 2 to 3 Years Experience Let's dive deep into the interview questions with answers. I have added many links in the article so that it will be helpful for you to get a detailed explanation of the question. I have categorized the interview questions into topics such as the OOPs concept, Collection framework, Exception Handling, String, Serialization, Java Multi-threading, and Coding basic questions. Relax, the expectation from the 2 to 4 years experienced guy is not the same as for senior java developers. In this post, I will be sharing the most frequently asked java interview questions for 2 to 4 years experienced.









Inheritance in java interview questions