Blog Archives

Java 8 Interview Questions Preparation Course

Java 8 is one of the major releases from Java with features like Streams, Lambdas etc. A lot of companies are looking for software developers proficient in Java 8 features. This course contains basic to expert level Java 8 interview

Posted in Java, Java 8, Java 8 Interview Questions

What are the main differences between an interface with default method and an abstract class in Java 8?

An interface with a default method appears same as an Abstract class in Java. But there are subtle differences between two. Instance variable: An interface cannot have instance variables. An abstract class can have instance variables. Constructor: An interface cannot

Posted in Java 8, Java 8 Interview Questions

What is a StringJoiner in Java 8?

StringJoiner is a new class in Java 8 that can be used to create a String. It can construct a sequence of characters separated by a delimiter. It can also optionally add a prefix and suffix to this sequence. We

Posted in Java 8, Java 8 Interview Questions

What is the type of a Lambda expression in Java 8?

The type of a lambda expression depends on the context it is being used. A lambda is like a method reference. It does not have a type of its own. Generally, a Lambda is an instance of a Functional Interface.

Posted in Java 8, Java 8 Interview Questions

What is the target type of a lambda expression ?

The target type of a lambda expression represents a type to which the expression can be converted. The target type for a lambda expression is a functional interface. The lambda expression must have same parameter type as the parameter in

Posted in Java 8, Java 8 Interview Questions

What are the popular annotations introduced in Java 8?

Some of the popular annotations introduced in Java 8 are: @FunctionalInterface: This annotation is used to mark an interface as Functional Interface. As mentioned earlier, A FunctionalInterface can be used for lambda expressions. @Repeatable: This annotation is used for marking

Posted in Java 8, Java 8 Interview Questions

How can we get current time by using Date/Time API of Java 8?

In Java 8 we can use Clock class to get the current time. Instead of using old method System.currentTimeMillis(), we can create a Clock object and call millis() method to get the current time in milliseconds. We can also call

Posted in Java 8, Java 8 Interview Questions

Is it possible to define a static method in an Interface?

Yes, from Java 8, an Interface can also has a static method.

Posted in Java 8, Java 8 Interview Questions

How can we analyze the dependencies in Java classes and packages?

Java 8 comes with a new command line tool jdeps that can help in analyzing the package-level and class-level dependencies. We can pass a jar file name or a class name as an argument to this tool. It will list

Posted in Java 8, Java 8 Interview Questions

What are the new JVM arguments introduced by Java 8?

In Java 8, PermGen space of ClassLoader is removed. It has been replaced with MetaSpace. Now we can set the initial and maximum size of MetaSpace. The JVM options -XX:PermSize and –XX:MaxPermSize are replaced by -XX:MetaSpaceSize and -XX:MaxMetaspaceSize respectively in

Posted in Java 8, Java 8 Interview Questions