Imp Question Bank
Imp Question Bank
1) What is Java?
Java is a cross-platform object-oriented programming language. It is
a general-purpose programming language intended to let application
developers “write once, run anywhere” (WORA),[17] meaning
that compiled Java code can run on all platforms that support Java without
the need for recompilation.
6) What is JVM?
JVM stand for Java Virtual Machine. JVM is a virtual machine that enables
the computer to run the Java program. JVM acts like a run-time engine
which calls the main method present in the Java code. JVM is the
specification which must be implemented in the computer system. The
Java code is compiled by JVM to be a Bytecode which is machine
independent and close to the native code.
7) What is 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.
8) What is 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
9) What is JIT?
JIT stand for Just-In-Time. It is compiler 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.
10) Why we call java code “write once and run anywhere”?
The bytecode. Java compiler converts the Java programs into the class file
(Byte Code) which is the intermediate language between source code and
machine code. This bytecode is not platform specific and can be executed
on any computer.
25)What is Constructor?
The constructor can be defined as the special type of method that is used
to initialize the state of an object. It is invoked when the class is
instantiated, and the memory is allocated for the object. Every time, an
object is created using the new keyword, the default constructor of the
class is called. The name of the constructor must be similar to the class
name. The constructor must not have an explicit return type.
29)What is Inheritance?
Inheritance is a mechanism by which one object acquires all the properties and
behavior of another object of another class. It is used for Code Reusability and
Method Overriding. The idea behind inheritance in Java is that you can create
new classes that are built upon existing classes. There are five types of
inheritance in Java.
Single-level inheritance
Multi-level inheritance
Multiple Inheritance
Hierarchical Inheritance
Hybrid Inheritance
31)What is association?
Association refers to the relationship between multiple objects. It refers to
how objects are related to each other and how they are using each other's
functionality. Composition and aggregation are two types of association.
32)What is aggregation?
Aggregation can be defined as the relationship between two classes where
the aggregate class contains a reference to the class it owns. Aggregation
is best described as a has-a relationship.
33)What is composition?
Holding the reference of a class within some other class is known as
composition. When an object contains the other object, if the contained
object cannot exist without the existence of container object, then it is
called composition. In other words, we can say that composition is the
particular case of aggregation which represents a stronger relationship
between two objects.
37)What is polymorphism?
Polymorphism is a concept by which we can perform a single action in
different ways. There are two types of polymorphism in Java: compile-time
polymorphism and runtime polymorphism. We can perform
polymorphism in java by method overloading and method overriding.
49)What is abstraction?
Abstraction is a process of hiding the implementation details and showing
only functionality to the user. It displays just the essential things to the
user and hides the internal information. There are two ways to achieve
the abstraction.
Abstract Class
Interface
50)What is abstract class?
A class that is declared as abstract is known as an abstract class. It needs
to be extended and its method implemented. It cannot be instantiated. It
can have abstract methods, non-abstract methods, constructors, and
static methods. It can also have the final methods which will force the
subclass not to change the body of the method.
51)What is interface?
The interface is a blueprint for a class that has static constants and
abstract methods. It can be used to achieve full abstraction and multiple
inheritance. There can be only abstract methods in the Java interface, not
method body. It is used to achieve abstraction and multiple inheritance in
Java.
57)What is package?
A package is a group of similar type of classes, interfaces, and sub-
packages. It provides access protection and removes naming collision. The
packages in Java can be categorized into two forms, inbuilt package, and
user-defined package. There are many built-in packages such as Java, lang,
awt, javax, swing, net, io, util, sql, etc.
58)What is encapsulation?
Encapsulation in Java is a mechanism of wrapping the data (variables) and
code acting on the data (methods) together as a single unit. In
encapsulation, the variables of a class will be hidden from other classes,
and can be accessed only through the methods of their current class.
Therefore, it is also known as data hiding.
87)What is string?
Strings, which are widely used in Java programming, are a sequence of
characters.
144) What are the constant defined in thread class for thread priority?
There are main 3 constant defined in thread class which are
public static int MIN_PRIORITY
public static int NORM_PRIORITY
public static int MAX_PRIORITY
Default priority of a thread is 5 (NORM_PRIORITY). The value of
MIN_PRIORITY is 1 and the value of MAX_PRIORITY is 10.
145) What is thread pool?
Thread pool represents a group of worker threads that are waiting for
the job and reuse many times. In case of thread pool, a group of fixed
size threads are created. A thread from the thread pool is pulled out and
assigned a job by the service provider. After completion of the job,
thread is contained in the thread pool again.
148) What are the classes and interfaces provided in this regex package?
The Matcher and Pattern classes provide the facility of Java regular
expression. The java.util.regex package provides following classes and
interfaces for regular expressions.
MatchResult interface
Matcher class
Pattern class
PatternSyntaxException class
184) What is difference b/w First level cache and Second level cache?
First Level Cache Second Level Cache
First Level Cache is associated with Second Level Cache is associated
Session. with SessionFactory.
It is enabled by default. It is not enabled by default.
It allows you to create only one instance of that test class on which it is
written otherwise instance of class will be created each time when a test
method is called of that class.
Events are named using camel case instead of just using the lowercase.
Events are passed as functions instead of strings.
The event argument contains a set of properties, which are specific to
an event. Each event type contains its own properties and behavior
which can be accessed via its event handler only.
251) If we create 2 instance of same class in bean then what happens? Like
<bean id=”one” class=”Employee.java”> <bean id=”two”
class=”Employee.java”>
https://stackoverflow.com/questions/19324508/define-two-beans-of-same-
class-in-single-application-context