Iterable Interface Iterator Interface Represents a collection that can be traversed using foreach loop. Allows to iterate over some other collection. The class that implements the iterable interface has to override iterator() method. hasNext() and next() methods of Iterator interface are to be overridden by class implementing it. Does not store the current state. Stores the…
Category: Interview questions
Comparable vs Comparator interface in Java
Comparable and Comparator both are interfaces and can be used to sort collection elements. There are many differences between Comparable and Comparator interfaces that are mentioned as follows: Comparable in Java Comparator in Java Comparable interface is used to sort the objects with natural ordering. Comparator in Java is used to sort attributes of different objects.…
String’s immutability in Java explained
String is immutable in Java. An immutable class is simply a class whose instances cannot be modified. All information in an instance is initialized when the instance is created and the information can not be modified. There are many advantages of immutable classes. This article summarizes why String is designed to be immutable. This post illustrate the immutability concept…
25 Most Common OOPS Interview Questions in Java
1.What is meant by Object Oriented Programming? OOP is a method of programming in which programs are organized as cooperative collections of objects. Each object is an instance of a class and each class belong to a hierarchy. 2.What is meant by Encapsulation? Encapsulation is the process of compartmentalizing the elements of an abstraction that defines…