Skip to content

Category Archives: Java

We can declare interfaces as members of a class or another interface. Such an interface is called a member interface or nested interface. Interface in… Read More
Java doesn’t support multi-value returns. We can use following solutions to return multiple values.   If all returned elements are of same type We can… Read More
One should have a strong understanding of this keyword in inheritance in Java to be familiar with the concept. Instance variable hiding refers to a… Read More
We know that a Java code begins to execute from the main method. During runtime, if JVM can’t find any main method then we will… Read More
Consider following program. class Main {     public static void main(String args[])     {         System.out.println("Hello");     } } Output: Hello Does JVM create an object of class Main?… Read More
Prerequisite: Collection in Java Following are the 4 ways to retrieve any elements from a collection object:   For-each For each loop is meant for traversing items… Read More
A new feature was introduced by JDK 7 which allows writing numeric literals using the underscore character. Basically, they are broken to enhance readability. This feature… Read More
Variable Arguments (Varargs) in Java is a method that takes a variable number of arguments. Variable Arguments in Java simplifies the creation of methods that… Read More
Reflection is an API that is used to examine or modify the behavior of methods, classes, and interfaces at runtime. The required classes for reflection… Read More
String is a sequence of characters. In java, objects of String are immutable which means a constant and cannot be changed once created. Creating a… Read More
Background : Iterator is an interface provided by collection framework to traverse a collection and for a sequential access of items in the collection.   // Iterating… Read More
This is a question asked quite often as in which language should be preferred to be efficient in competitive programming. It is something one should… Read More
Java HashSet class implements the Set interface, backed by a hash table which is actually a HashMap instance. No guarantee is made as to the… Read More
In Java, an immutable class is a class (Integer, Byte, Long, Float, Double, Character, Boolean, and Short) which once created then its body can not… Read More
An assertion allows testing the correctness of any assumptions that have been made in the program. An assertion is achieved using the assert statement in… Read More