Interview Questions and Answers on Java 5 Concepts

Q1.  What are concepts introduced with Java 5 ?

Ans. Generics , Enums , Autoboxing , Annotations and Static Import.

Q2.  What are the Wrapper classes available for primitive types ?

Ans. boolean  - java.lang.Boolean
byte - java.lang.Byte
char - java.lang.Character
double - java.lang.Double
float - java.lang.Float
int - java.lang.Integer
long - java.lang.Long
short - java.lang.Short
void - java.lang.Void

Q3.  When were Enums introduced in Java ?

Ans. Enums were introduced with java 5.

Q4.  Explain Autoboxing ?

Ans. Autoboxing is the automatic conversion that the Java compiler makes between the primitive types and their corresponding object wrapper classes

Q5.  What is an Enum type ?

Ans. An enum type is a special data type that enables for a variable to be a set of predefined constants

Q6.  What is a Static import ?

Ans. By static import , we can access the static members of a class directly without prefixing it with the class name.

Q7.  What is Scanner class used for ? when was it introduced in Java ?

Ans. Scanner class introduced in Java 1.5 for reading Data Stream from the imput device. Previously we used to write code to read a input using DataInputStream. After reading the stream , we can convert into respective data type using as String ,in.nextInt() as integer, in.nextDouble() as Double etc