Here Are the Most Frequently asked Core Java Interview Questions and Answers.
In this tutorial, We have covered New Release Core Java interview questions, Please go through this before you head up for freshers and experienced interview on Java.
1 ) Tell some important features of Java version 14 ?
Java version 14 was released on March 17, 2020. It is a Non-LTS version. Some of the developer specific Java 14 Features are:
- Switch Expressions
- Pattern matching improvements of instanceof operator – Preview Feature
- Helpful NullPointerException Messages
- Text Blocks – Second Preview
- Records – data class, preview feature
2) Tell some important features of Java version 13 ?
Some of the developer specific Java 13 Features are:
- Text Blocks – Preview Feature
- Switch Expressions – Preview Feature
- Re-implementation of Java Sockets API
- Dynamic CDS Archive
- FileSystems.newFileSystem() Method
- DOM and SAX Factories with Namespace support
- Unicode 12.1 support
- ZGC improvements to return Unused Memory
3) Tell me some important features of Java version 12 ?
Java 12 was launched on March 19, 2019. It is a Non-LTS version. Some of the Java 12 Features are:
- Switch Expressions
- File mismatch() Method
- Compact Number Formatting
- Teeing Collectors in Stream API
- New Methods in String Class
- JVM Constants API
- Pattern Matching for instanceof
- Raw String Literals is Removed From JDK 12.
4) What are the important features of Java version 11 ?
Java 11 is the second LTS release after Java 8. They’ve changed the licensing and support model which means if you download the Java 11 Oracle JDK, it will be paid for commercial use. If you want to use a free version, you can download it from the OpenJDK website.
Important features are as below :
- We can run a java program directly through java command. The source file will be implicitly compiled and executed.
- There are new methods added in String class – isBlank(), lines(), strip(), stripLeading(), stripTrailing(), and repeat().
- Files class got two new methods to read/write string data – readString() and writeString().
- We can use “var” with lambda expressions also.
- Epsilon: A No-Op Garbage Collector for test environments.
- Java EE and CORBA Modules have been removed from the standard JDK build.
5) What are the important features of Java 9 release?
The Java 9 was a major release and comes with a lot of features. Some of the important features are:
- Java 9 REPL (JShell)
- Java 9 Module System
- Factory Methods for Immutable List, Set, Map and Map.Entry
- Private methods in Interfaces
- Reactive Streams
- GC (Garbage Collector) Improvements
6) What are the important features of Java 8 release?
It is most asked interview question in the java programming. Below are the features:
- Interface changes with default and static methods
- Functional interfaces and Lambda Expressions
- Java Stream API for collection classes
- Java Date Time API
7) What are the OOPS Concepts in Java?
Java is Object Oriented Programming Concepts, Below are some of the OOPS concepts in java programming:
8) What do you understand by platform independence of Java?
Platform independence means that you can run the same Java Program in any Operating System. For example, you can write java program in Windows and run it in Linux.
9) What is JVM (Java Virtual Machine) and is it platform independent?
Java Virtual Machine (JVM) is actually the heart of java programming language. JVM is responsible for converting byte code into machine-readable code. The JVM is platform-dependent, that’s we have different JVM for different operating systems. We can customize JVM with Java Options, such as allocating minimum and maximum memory to JVM. It’s called virtual because it provides an interface that doesn’t depend on the underlying OS.
10) Explain difference between JDK and JVM?
Java Development Kit (JDK) provides all the tools, executables and binaries required to compile, debug and execute a Java Programs.
Java Virtual Machine (JVM) executes the java programs.
11) What is the difference between JVM and JRE?
Java Runtime Environment (JRE) is the implementation of JVM. JRE consists of JVM and java binaries and other classes to execute any program successfully. JRE doesn’t contain jdk. If you want to execute any java program, you should have JRE installed.
12) What is the superclass of all classes in Java?
java.lang.Object is the root class for all the java classes.
13) Does java support multiple inheritance?
Yes, We can achieve multiple inheritance using interface implementation in Java.
14) Why People say Java is not pure Object Oriented language?
Java is not said to be pure object-oriented because it supports primitive types such as int, byte, short, long, etc.
15) What is difference between path and classpath variables?
PATH is an environment variable used by the operating system to locate the executables classes. That’s why when we install Java or want any executable to be found by OS, we need to add the directory location in the PATH variable.
Classpath is specific to Java and used by java executables to locate class files. We can provide the classpath location while running java application and it can be a directory, ZIP files, JAR files, etc.
16) Explain the use of main method in Java?
main() method is the entry point of any standalone java application.
Java’s main method is public and static so that Java runtime can access it without initializing the class. The input parameter is an array of String through which we can pass runtime arguments to the java program.
17) What is overloading and overriding in java?
Overloading is about having same function with different signatures. Overriding is about same function, same signature but different classes connected through inheritance. Overloading is an example of compile time polymorphism and overriding is an example of run time polymorphism.
18) Can we overload main method?
Yes we can have multiple main method in a single class. However if we run the class, java runtime environment will look for main method with syntax as public static void main(String args).
19) Can we have multiple public classes in a java source file?
No we can not have more than one public class in a single java source file. A single source file can have multiple classes but can only have one public class.
20) What is package in Java ?
Java package is the mechanism to organize the java classes by grouping them.
We can have the grouping logic based on functionality or modules. A java class fully classified name contains package and class name.Example, java.lang.Object is the fully classified name of Object class that is part of java.lang package.