Basic Java Interview Questions and Answers
Basic Java interview questionsThese Basic Java questions have been designed for various interviews, competitive exams and entrance tests. We have covered questions on both basic and advanced concepts which will help you improve your skills to face interview questions on Basic Java.
Who is this Basic Java interview questions designed for?All the developers, programmers and software engineers will find these questions extremely useful. All freshers, BCA, BE, BTech, MCA and college students wanting to make a career in Software Development will be highly benefited by these questions.
Basic Java interview questions topicsThis section covers Java topics like - Just-In-Time compiler, class, Singleton class, static variable, access modifier, String, garbage collection, Polymorphism , method overloading, constructors, multi-threading, destructors , Interface, exception handling, inheritance etc.
1. How Java enabled High Performance?
Java uses Just-In-Time compiler to enable high performance.
Java source code is first compiled into byte code. These byte codes are then executed by JVM. But execution of byte code is slower than execution of machine language code, because JVM first needs to translate byte code into machine language code. Now here come Java JIT compiler that turns Java bytecode into instructions, compiling it "just in time" to run that can be sent directly to the processor.
2. Why Java is considered dynamic?
Dynamic refer as the things which are executed when required rather than in advance. Java is considered as dynamic because of Bytecode. A source code written in one platform, the same code can be executed in any platform. Java is designed to adapt to an evolving environment. Java also loads the class files at runtime.
3. What is JIT compiler?
In Java, a just-in-time (JIT) compiler is a program that turns Java bytecode into instructions that can be sent directly to the processor. Just-In-Time(JIT) compiler is used to improve the performance.
4. Define class.
A class is a template that is used to create objects. A class contains fields and methods to describe the behavior of an object.
5. What is Singleton class?
Singleton class controls object creation. It allows only one instance of itself to be created. This class is helpful when a user wants to restrict instantiation of a class to only one object. For example, if you want only one connection to a database due to licensing issues, you can use Singleton class in such scenario.
6. What is a static variable?
static variable is a class level variable and common to all the instances of the class. Only a single copy of static variable is created and shared among all the instances of the class.
It is declared with the static keyword in a class, but outside a method, constructor or a block.