Java Interview questions for freshers as well 1 to 3 year experienced on advance and basic Java, J2ME, J2ee, Servlet, JSP, Struts, Spring, hibernate framework with examples that cover the essentials of java j2ee means all type of java questions covered under this page and also a form is given at the end of this page for those user who want more Interview questions and answer on core and advanced java just need to fill the form and send us we will send all the answers to them and it for both freshers and experienced condidate and also chat option is given in right hand side for directly chat with expert for answers
|Questions : 1||What is JVM (Java Virtual Machine) ?|
|Answers : 1||
JVM stands for Java Virtual Machine. It’s an abstract computer or virtual computer which runs the compiled java programs. Actually JVM is a software implementation which stands on the top of the real hardware platform and operating system. It provides abstraction between the compiled java program and the hardware and operating system. So the compiled program does not have to worry about what hardware and operating system he has to run in, it’s all handled by the JVM and thus attaining portability. All Java programs are compiled in to bytecodes. JVM can only understand and execute Java bytecodes. we can visualize Java bytecodes as machine language for JVM. Java compiler takes the .java files and compiles it to a “bytecode” file with .class file extension. Compiler generates one class file for one source file.
|Questions : 2||What is JIT (Just-in-Time) Compilation ?|
|Answers : 2||
|Questions : 3||How do you implement inheritance in Java?|
|Answers : 3||
nheritance is implemented by using “EXTEND” keyword.
|Questions : 4||How can we implement polymorphism in Java ?
|Answers : 4||
Polymorphism is the capability of an action or method to do different things based on the
object that it is acting upon. There are two types of polymorphism:-
|Questions : 5||What are packages ?|
|Answers : 5||
Packages group related classes and interfaces together and thus avoiding any name conflicts. From OOP’s point of view packages are useful for grouping related classes together. Classes are group together in a package using “package” keyword.
|Questions : 6||What is the use if “instanceof” keyword ?|
|Answers : 6||
“ instanceof ” keyword is used to check what is the type of object. F
|Questions : 7||What are Native methods in Java ?|
|Answers : 7||
There may be times when we want to call subroutines which are written in some other language other than Java like C++, VB6 etc.
|Questions : 8||Explain in depth Garbage collector ?|
|Answers : 8||
Garbage collection is the process of automatically freeing objects that are no longer referenced by the program. This frees the programmer from having to keep track of when to free allocated memory, thereby preventing many potential bugs. Thus making programmers more productive as they can now put more effort in coding rather than worrying about memory management.
The only disadvantage of garbage collector is it adds overheads. Because the JVM (Java virtual machine) has to keep a constant track of the objects which are not referenced and then free these unreferenced objects on fly. This whole process has a slight impact on the application performance. But garbage collector has a good algorithm and it runs in its own thread thus having a least impact on the application performance but still it has some impact.
|Questions : 9||How can we force the garbage collector to run?|
|Answers : 9||
Garbage collector can be run forcibly using “System.gc()” or “Runtime.gc()”
|Questions : 10||What’s the use of JAVAP tool ?|
|Answers : 10||
javap disassembles compiled Java files and spits out representation of the Java program. This is a useful option when the original source code is not available.
|Questions : 11||What are applets ?|
|Answers : 11||
Applets are small applications that are accessed from web server automatically installed,
and run from the browser. Once an applet arrives on the client it has limited access to
resources thus ensuring security for the end user. An applet is controlled by the software
that runs it. Usually, the underlying software is a browser, but it can also be applet viewer.
If you run the applet source code from eclipse it runs inside an applet viewer. All applets
should inherit from applet class.
|Questions : 12||In which package is the applet class located?|
|Answers : 12||
Applet classes are located in " java.applet "package.
|Questions : 13||How can you copy one array in to a different array?|
|Answers : 13||
System.arraycopy(myOldArray, 0, myNewArray, 0, length);+
|Questions : 14||Can you explain the core collection interfaces?|
|Answers : 14||
There are six interfaces and come under two different inheritance group one which comes under the collection interface root and the other in the map interface root.
|Questions : 15||what’s the main difference between ArrayList / HashMap and Vector / Hashtable?|
|Answers : 15||
Vector / HashTable are synchronized which means they are thread safe. Cost of thread
safe is performance degradation. So if you are sure that you are not dealing with huge number of threads then you should use ArrayList / HashMap.But yes you can still
|Questions : 16||what is a StringBuffer class and how does it differs from String class?|
|Answers : 16||
StringBuffer is a peer class of String that provides almost all functionality of strings. String represents fixed-length, immutable character sequences. Comparatively StringBuffer represents mutable, growable and writeable character sequences. But StringBuffer does not create new instances as string so it’s more efficient when it comes to intensive concatenation operation.
|Questions : 17||What is JAVAdoc utility?|
|Answers : 17||
Javadoc parses comments in JAVA source files and produced HTML pages for the same.
Below is the syntax for the same
javadoc [ options ] [ packagenames ] [ sourcefiles ] [ @files ]
Arguments can be in any order.
Options Command-line options that is doctitle, windowtitle, header, bottom etc
|Questions : 18||How much subclasses you can maximum in Inheritance?|
|Answers : 18||
In one of our old JAVA projects we had an inheritance depth of five. Believe us we never liked that code. It’s bad to have a huge inheritance depth. A maintainable inheritance depth should be maximum 5. Anything above that is horrible. There is no limit as such specified anywhere that there is some limit on the inheritance sub classing . But depending on environments you will get stack over flow error.