Java Iterator is used to iterate over 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. Second, names are shortened and improved in Iterator, by the way, you can see the difference between Iterator and Enumeration for more differences. It's one of the frequently asked Java Interview questions. An iterator is an interface and enhanced to support Generic from Java 1.5 release.
The HashMap in Java is one of the most popular Collection class among Java programmers. After my article on How HashMap works in Java, which describes theory part of Java HashMap and becomes hugely popular among Java programmers, I thought to share how to use HashMap in Java with some fundamental HashMap examples, but couldn't do that earlier and it was slipped. The HashMap is a data structure, based on hashing, which allows you to store an object as key value pair, an advantage of using HashMap is that you can retrieve object on constant time i.e. O(1) if you know the key. The HashMap class implements Map interface and supports Generics from Java 1.5 release, which makes it type safe. There are a couple of more Collections, which provides similar functionalities like HashMap, which can also be used to store key value pair. Hashtable is one of them, but Hashtable is synchronized and performs poorly in a single threaded environment. See Hashtable vs HashMap for complete differences between them. Another one, relatively new is ConcurrentHashMap, which provides better performance than Hashtable in a concurrent environment and should be preferred. See the difference between ConcurrentHashMap and HashMap for detail differences.
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.
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 contains bytecode. These byte codes are then executed by JVM. Now here comes JIT. Since the execution of bytecode is slower than the execution of machine language code, because JVM first needs to translate bytecode into machine language code.
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.
Class and Object are two pillars of Java programming language. There are multiple ways you can describe Class in Java, for someone Class is a user defined type, for others it's blueprint to create objects and for few of other it's just a way to model real world entity. Questions come why do we need Class in Java, well one thing I can think of is to combine multiple types into one structure. Class and Object along with core OOPS concept e.g. Abstraction, Encapsulation, Inheritance and Polymorphism is the first thing any Java programmer learn. I have just finished a basic Java presentation on Class for beginners which gives an introduction of What is Class in Java and details some important details about Java Classes.
When you start learning JDBC in Java, the first program you want to execute is connected to database from Java and get some result back by executing some SELECT queries. In this Java program, we will learn How to connect to MySQL database from Java program and execute a query against it. I choose MySQL database because it's free and easy to install and setup. If you are using Netbeans IDE then you can connect MySQL Server directly from Netbeans, Which means in one window you could be writing Java code and other you can write SQL queries. Another advantage of using MySQL database is that it provides type 4 JDBC driver bundled in mysql-connector-java-5.1.17-bin.jar which is easy to use. By the way, if you are using Oracle database then you can check Java program to connect Oracle database, to connect and run SQL queries against Oracle DB.