HTML

How to use Iterator Java - Example Tutorial

The Iterator is used to iterate over all elements of a Collections in Java. By Iteration, I mean, going over each element stored in the collection and optionally performing some operation e.g. printing value of an element, updating object or removing an object from Collection. Iterator was not part of first Java release, and a similar class Enumeration was there to provide Iteration functionality. Iterator in Java was introduced from JDK 1.4 and it provides an alternative to Enumeration, which is obsolete nowadays. An iterator is different to Enumeration in two main ways, first, Iterator allows a programmer to remove elements from Collection during iteration.

Difference between JDK and JRE in Java Platform

Java Platform offers JRE and JDK to run Java programs. JRE stands for Java runtime environment and JDK stands for Java development kit. JRE is meant for normal users, who wants to run Java program in their computer. JRE is normally used to run Java programs downloaded over internet e.g. Java Applets and Java Desktop application built using AWT and Swing. The main difference between JRE and JDK, comes from the fact that they are different tools. JDK is created for Java programmers and contains tools required for Java programming, e.g. javac for compiling Java source files to .class files. Without JDK, you can not create Java applications and programs. By the way, JDK comes with its own JRE, but when you run Java program using java command, the JRE which comes first in System PATH is used for execution.

Difference between JIT and JVM in Java - Interview Question

The main difference between JIT and JVM is that JIT is part of JVM itself and its main function is to improve the performance of JVM by directly compiling some hot code (code which executes above a certain threshold) into native instruction. JIT stands for Just In time compilation and JVM stands for Java Virtual Machine. JVM is a virtual machine used in Java programming platform to execute or run Java programs. The main advantage of JVM is that JVM  makes Java platform-independent by executing bytecodes. Java source code is compiled into class files, which contain bytecode.

Can abstract class have Constructor in Java - Interview Question

Yes, an abstract class can have a constructor in Java. You can either explicitly provide a constructor to abstract class or if you don't, the compiler will add default constructor of no argument in abstract class. This is true for all classes and it also applies to an abstract class. For those who want to recall what is an abstract class in Java, it's a class which can not be instantiated with new() operator or any other ways. In order to use an abstract class in Java,  You need to extend it and provide a concrete class. Abstract class is commonly used to define a base class for a type hierarchy with default implementation, which is applicable to all child classes. By the way, difference between interface and abstract class in Java is also one of the popular and tricky Java questions and should be prepared well for Java interviews.