Top 21 Frequently Asked Java Interview Questions Answers | Java67The main distinction between fail-fast and fail-safe iterators is whether or not the collection can be modified while it is being iterated. Fail-safe iterators allow this; fail-fast iterators do not. Fail-fast iterators operate directly on the collection itself. During iteration, fail-fast iterators fail as soon as they realize that the collection has been modified i. Fail-safe iterates operate on a cloned copy of the collection and therefore do not throw an exception if the collection is modified during iteration.
Top 21 Frequently Asked Java Interview Questions Answers
Can you please share a list of frequently asked Java programs on Interviews as well? Interesting question, some of the frquently asked programs on Java interviews are : - reverse string without using stringbuffer - writing code to avoid deadlock - four ways to loop over map - multi-threaded version of getInstance method of Singleton class - count number of 1 in an integer number - converting string to bytes etc. Great article. In 5, the Singleton example - you may want to show the private constructor method for the SingletonClass. As written, you could create multiple instances of the SingletonClass, each with their own DCL object.
Join the Toptal community.
What is the difference between an Inner Class and a Sub-Class? Ans: An Inner class is a class which is nested within another class. An Inner class has access rights for the class which is nesting it and it can access all variables and methods defined in the outer class. A sub-class is a class which inherits from another class called super class. Sub-class can access all public and protected methods and fields of its super class.