Java Interview Questions

Explain about the dynamic feature of Java?

Java's dynamic feature is designed to suit the needs of an evolving environment. An extensive amount of runtime information can be carried by Java programs which can be used for the purpose of resolving and verifying the accesses to objects during runtime.

 

How can you relate the concept of Java Virtual Machine (JVM) to Java's platform-independent feature?

The concept of Java Virtual Machine fits into the context of Java's platform-independent feature when a Java program is compiled. During the compilation, the program will not be compiled into platform specific machine, instead into platform independent byte code. After this process, irrespective of any platform that the particular Java program is being run, the bytecode will be distributed over the web and interrupted by JVM.

 

What is the method used to get the primitive data type of a particular string?

parseInt() is the method used to get the primitive data type of any particular string.

 

What are the classes does java.util.regex consist of?

There are three classes in java.util.regex such as Matcher class, PatternSyntaxException class, and Pattern class.

 

What is the major advantage of a byte data type?

As a byte is four times larger than an int, the byte data type is mainly used is some amount of significant space has to be preserved in a large array, most importantly in place of integers.

 

List down any five of the predominant features of Java.

Platform independent

Robust

Object oriented

Multi-threaded and

Interpreted

 

What is the significance of Synchronized NonAccess Modifier in Java?

Apart from access modifiers, Java provides the NonAccess modifier functionalities that can be synchronized. The main feature of these functionalities is that after synchronization there will be an indication that a method can be used by only one thread at a time.

 

What is Set Interface?

The Set Interface is a collection of elements primarily used to avoid duplicate elements. Methods that are inherited from the collection will only be present in the Set Interface which incorporates the restriction that duplicate elements should be prohibited.

 

Define JAR file?

JAR file is defined as Java Archive file and it combines two or more files into one. The Java classes will be confined within a library. The .JAR files will be built on Zipping file format with the .jar file extension.

 

Double value cannot be cast to a byte. True or false?

False. A double value can be cast to a byte.