Interview Question and Answer
Top 10 Java Interview Question and Answer.
What is Difference between JRE, JDK and JVM?
JRE: JRE(Java Run-time Environment) is the implementation of JVM.
JDK: JDK (Java development Kit)is Physically exists It Contains JRE Development tools.
JDK: JDK (Java development Kit)is Physically exists It Contains JRE Development tools.
JVM: JVM (Java virtual machine) is an abstract machine which provides the run-time environment in which java byte code can be executed. JVM are available for Many hardware and Software platforms so JVM is platform Dependent.
What is JIT Compiler ?
Just in-time(JIT)compiler is used to improve the performance. JIT Compiler parts of the byte code 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 JVM to the instruction set of a specific CPU (central processing unit).
What is class loader ?
The class loader is a subsystem of JVM that is used to load classes and interfaces.
There are many type of class loader.
- Bootstrap Class Loader.
- Extension Class Loader.
- System Class Loader.
- Plugin Class Loader.
Is "Empty.java" file name a valid source file name ?
Yes, Save your java file only ".java" extension but compile it by "javac filename.java" and Run by "java filename".
Access Modifiers in java?
There are two type of Modifiers in java.
What is Package in java With Advantage?
A java package is a group of similar types of classes, interfaces and sub-packages. Package in java can be categorized in two form, built-in package and user-defined package.
Advantage of Package:
Syntax: javac -d directory javafilename.
There are two type of Modifiers in java.
- Access Modifiers: There are many access Modifiers such as Private, Default, Protected and Public.
- Public: A class or interface may be accessed from outside the package. Constructors, inner classes, methods and field variables may be accessed wherever their class is accessed.
- Protected: Accessed by other classes in the same package or any sub classes of same package or different package.
Default or No-access modifiers: Members of a class which are defined with no access modifiers are visible within the package in which they are defined.
-
Private: Accessed only within the class in which they are declared.
- Non-access Modifiers: There are many non-access modifiers such as Static, abstract, synchronized, native, volatile, transient etc.
- static : This modifier is used to specify whether a member is a class member or an instance member.
final : It is used to restrict the further modification of a class or a method or a field.
abstract : abstract class or abstract method must be enhanced or modified further.
synchronized : It is used to achieve thread safeness. Only one thread can execute a method or a block which is declared as synchronized at any given time.
Transient: Transient is basically a variables modifier that used for serialization.
- Now, what is Serialization? Serialization in Java is a mechanism that is used in
- converting the state of an object into a byte stream. At the time of serialization,
- if you don’t want to save the value of a particular variable in a file, then use the transient keyword.
- Syntax: private transient <member variable>;
- or
- transient private <member variable>;
In case you define any data member as transient, it will not be serialized.
This is because every field marked as transient will not be serialized. You can use this transient
keyword to indicate the Java virtual machine (JVM) that the transient variable is not part of the
persistent state of an object.
What is Package in java With Advantage?
A java package is a group of similar types of classes, interfaces and sub-packages. Package in java can be categorized in two form, built-in package and user-defined package.
Advantage of Package:
- Java Package provides access protection.
- Package is used to categorize the classes and interfaces so that they can be easily maintained.
Syntax: javac -d directory javafilename.
How to access package from another Package?
There are three ways to access the package from outside the package.
- import package.*;
- import package.classname;
- fully qualified name.
DATA TYPE
|
DEFAULT VALUE
|
DEFAULT SIZE
|
Boolean
|
false
|
1 bit
|
byte
|
0
|
1 byte
|
char
|
'\u0000'
|
2 byte
|
short
|
0
|
2 byte
|
int
|
0
|
4 byte
|
float
|
0.0f
|
4 byte
|
long
|
0L
|
8 byte
|
double
|
0.0d
|
8 byte
|
object
|
null
|
-
|
Why char use 2 byte in java and what is \u0000?
"\u0000" is the lowest range of unicode system.
- Lowest Value: \u0000.
- Highest Value: \uffff.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment
Please Write a Message for Programming or something Related issues.