What is JAVA?
Java is a high-level programming language and is platform independent. Java is a collection of objects. It was developed by Sun Microsystems. There are a lot of applications, websites and Games that are developed using Java.

What are the features in JAVA?
Features of Java:
- Oops concepts
- Object-oriented
- Inheritance
- Encapsulation
- Polymorphism
- Abstraction
- Platform independent: A single program works on different platforms without any modification.
- High Performance: JIT (Just In Time compiler) enables high performance in Java. JIT converts the bytecode into machine language and then JVM starts the execution.
- Multi-threaded: A flow of execution is known as a Thread. JVM creates a thread which is called main thread. The user can create multiple threads by extending the thread class or by implementing Runnable interface. For more info Java Online Course
What do you mean by Constructor?
The points given below explain what a Constructor is in detail:
- When a new object is created in a program a constructor gets invoked corresponding to the class.
- The constructor is a method which has the same name as class name.
- If a user doesn’t create a constructor implicitly a default constructor will be created.
- The constructor can be overloaded.
- If the user created a constructor with a parameter then he should create another constructor explicitly without a parameter.
List the features of Java Programming language.
There are the following features in Java Programming Language.
- Simple: Java is easy to learn. The syntax of Java is based on C++ which makes easier to write the program in it.
- Object-Oriented: Java follows the object-oriented paradigm which allows us to maintain our code as the combination of different type of objects that incorporates both data and behavior.
- Portable: Java supports read-once-write-anywhere approach. We can execute the Java program on every machine. Java program (.java) is converted to bytecode (.class) which can be easily run on every machine.
- Platform Independent: Java is a platform independent programming language. It is different from other programming languages like C and C++ which needs a platform to be executed. Java comes with its platform on which its code is executed. Java doesn’t depend upon the operating system to be executed.
- Secured: Java is secured because it doesn’t use explicit pointers. Java also provides the concept of ByteCode and Exception handling which makes it more secured.
- Robust: Java is a strong programming language as it uses strong memory management. The concepts like Automatic garbage collection, Exception handling, etc. make it more robust.
- Architecture Neutral: Java is architectural neutral as it is not dependent on the architecture. In C, the size of data types may vary according to the architecture (32 bit or 64 bit) which doesn’t exist in Java.
- Interpreted: Java uses the Just-in-time (JIT) interpreter along with the compiler for the program execution.
- High Performance: Java is faster than other traditional interpreted programming languages because Java bytecode is “close” to native code. It is still a little bit slower than a compiled language (e.g., C++).
- Multithreaded: We can write Java programs that deal with many tasks at once by defining multiple threads. The main advantage of multi-threading is that it doesn’t occupy memory for each thread. It shares a common memory area. Threads are important for multi-media, Web applications, etc.
- Distributed: Java is distributed because it facilitates users to create distributed applications in Java. RMI and EJB are used for creating distributed applications. This feature of Java makes us able to access files by calling the methods from any machine on the internet.
- Dynamic: Java is a dynamic language. It supports dynamic loading of classes. It means classes are loaded on demand. It also supports functions from its native languages, i.e., C and C++.
What is the difference between JDK, JRE, and JVM?
JVM
JVM is an acronym for Java Virtual Machine; it is an abstract machine which provides the runtime environment in which Java bytecode can be executed. It is a specification which specifies the working of Java Virtual Machine. Its implementation has been provided by Oracle and other companies. Its implementation is known as JRE.
JVMs are available for many hardware and software platforms (so JVM is platform dependent). It is a runtime instance which is created when we run the Java class. There are three notions of the JVM: specification, implementation, and instance.
JRE
JRE stands for Java Runtime Environment. It is the implementation of JVM. The Java Runtime Environment is a set of software tools which are used for developing Java applications. It is used to provide the runtime environment. It is the implementation of JVM. It physically exists. It contains a set of libraries + other files that JVM uses at runtime. Learn more skills from Java online Training
JDK
JDK is an acronym for Java Development Kit. It is a software development environment which is used to develop Java applications and applets. It physically exists. It contains JRE + development tools. JDK is an implementation of any one of the below given Java Platforms released by Oracle Corporation:
- Standard Edition Java Platform
- Enterprise Edition Java Platform
- Micro Edition Java Platform
How many types of memory areas are allocated by JVM?
Many types:
- Class(Method) Area: Class Area stores per-class structures such as the runtime constant pool, field, method data, and the code for methods.
- Heap: It is the runtime data area in which the memory is allocated to the objects
- Stack: Java Stack stores frames. It holds local variables and partial results, and plays a part in method invocation and return. Each thread has a private JVM stack, created at the same time as the thread. A new frame is created each time a method is invoked. A frame is destroyed when its method invocation completes.
- Program Counter Register: PC (program counter) register contains the address of the Java virtual machine instruction currently being executed.
- Native Method Stack: It contains all the native methods used in the application.
What is JIT compiler?
Just-In-Time(JIT) compiler: It is used to improve the performance. JIT compiles parts of the bytecode that have similar functionality at the same time, and hence reduces the amount of time needed for compilation. Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.
Explain the JVM architecture?
Java Virtual Machine contains key components which are classloader, memory area, execution engine etc.
a) Classloader
It is a subsystem of JVM which load class files. Whenever a Java program is run, it is loaded by the classloader.
b) Class Area
Class Area holds class level data of each class file such as metadata, constant run pool, and static variables.
c) Heap
It is the runtime data which is used for allocating objects.
d) Stack
The stack is used for storing temporary variable. This component has a stack frame which is allocated one frame to each thread and when the execution of the thread is completed then that frame is also gets destroyed.
e) Registers
This component contains the address of JVM instruction which currently being executed.
f) Native Method Stack
All the native method stack used in the application are stored in this.
g) Execution Engine
It contains:
- A virtual processor
- An interpreter that executes the instructions after reading the bytecode.
- JIT compiler, used for improving the performance due to the slow execution. It compiles the similar part of the bytecode at the same time which reduces the total time needed for compilation.
h) Java Native Interface
It provides an interface which is needed for communicating with another application developed in another language like C, C++, C# etc.
To get in-depth knowledge, enroll for live free demo on Java Certification Course
What is the inner and anonymous inner class?
Answer: In Java, we can define a class inside a class and they are called nested classes. Any nested class which is non-static are known as inner class. Inner classes are associated with objects of the class and they can access all the variables and methods of the outer class.
Any local inner class without any name is known as an anonymous inner class. It is defined and instantiated in a single statement. Anonymous inner class always extend a class or implement an interface. Since an anonymous inner class doesn’t have any name, it is not possible to create its constructor.
What is break and continue statement?
Answer: In a while or do-while loop, we use break for a statement to terminate the loop. We use a break statement in a switch statement to exit the switch case. We can also use break statement for terminating the nested loop.
The continue statement is used for skipping the current iteration of a for, while or do-while loop. We can use the break statement with a label to skip the current iteration of the outermost loop.
The most basic programming question, not only related to the Java. If you have some knowledge of programming languages, you should know the answer to this question as it is among frequently asked Java interview questions for freshers.
What is data encapsulation and what’s its significance?
Encapsulation is a concept in Object Oriented Programming for combining properties and methods in a single unit.
Encapsulation helps programmers to follow a modular approach for software development as each object has its own set of methods and variables and serves its functions independent of other objects. Encapsulation also serves data hiding purpose.
What is a singleton class? Give a practical example of its usage.
A singleton class in java can have only one instance and hence all its methods and variables belong to just one instance. Singleton class concept is useful for the situations when there is a need to limit the number of objects for a class.
The best example of singleton usage scenario is when there is a limit of having only one connection to a database due to some driver limitations or because of any licensing issues.
What are Loops in Java? What are three types of loops?
Looping is used in programming to execute a statement or a block of statement repeatedly. There are three types of loops in Java:
1) For Loops
For loops are used in java to execute statements repeatedly for a given number of times. For loops are used when number of times to execute the statements is known to programmer.
2) While Loops
While loop is used when certain statements need to be executed repeatedly until a condition is fulfilled. In while loops, condition is checked first before execution of statements.
3) Do While Loops
Do While Loop is same as while loop with only difference that condition is checked after execution of block of statements. Hence in case of do while loop, statements are executed at least once.
Take your career to new heights of success with a Learn Java Online
What is difference between checked and unchecked Exception in Java.
Another java interview question for 2 to 4 years experienced Java programmer from Exception handling. key point to mention here is that checked Exception requires mandatory exception handling code while unchecked doesn’t.
Write Java program to reverse String in Java without using StringBuffer?
Another Java coding interview question asked on 2 ot 4 years experienced Java developer. Many times interviewer specifically mentioned that you can not use StringBuffer because it has reverse() method which makes this taks trivial. So you must know how to do this by using iteration as well as recursion to perform well.
What is difference between path and classpath variables?
PATH is an environment variable used by the operating system to locate the executables. 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.
Can you list down some of important method from object class?
Important methods of object classes are:
- hashcode : It returns hash value of the object
- equals : It compares the object references
- wait : It causes current thread to wait until notify or notifyAll is not called
- notify : Wakes up single thread which is waiting for lock
- notifyAll: Wakes up all threads which is waiting for lock
- toString : Provides String representation of the object
- clone : This method is used to clone the object
- finalize: This method is called when object is being garbage collected.