Core Java - Interview Questions and Answers for 'Jvm' | Search Interview Question - javasearch.buggybread.com
Javasearch.buggybread.com

Search Interview Questions


 More than 3000 questions in repository.
 There are more than 900 unanswered questions.
Click here and help us by providing the answer.
 Have a video suggestion.
Click Correct / Improve and please let us know.
Label / Company      Label / Company / Text

   



Core Java - Interview Questions and Answers for 'Jvm' - 47 question(s) found - Order By Rating

next 30
 Q1. What are different methods to get the permanent gen space of running application?Core Java
 This question was recently asked at 'Apcolite'.This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  memory management     Asked in 1 Companies      advanced


 Q2. Difference between JVM, JRE and JDK ?Core Java
Ans. JDK(Java Development kit) = Development Kit comprising of JVM , library and development tools for developers

JRE (Java Run time Environment) - Comprise of JVM and set of libraries

JVM(Java Virtual Machine) = Interpreter which reads the .class file line by line.

When we install JDK, JRE also get installed so we can write,compile and excute our code. Used by developer. Without JDK we can only execute the program using JRE.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  jre  jdk  jvm vs jre vs jdk     Asked in 4 Companies


 Q3. Why is JVM called Virtual machine ?Core Java
 This question is still unanswered. Can you please provide an answer.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm


 Q4. In which memory segment - heap or stack, the following stored by JVM

1. static members
2. objects
3. object references
4. local or method variables

Core Java
Ans. static members are stored in method area of heap

objects are stored on heap

object references are stored on stack

local or method variables are stored on stack

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  memory management  stack  heap


 Q5. Is JDK required on each machine where a Java application needs to be run ?Core Java
Ans. No, to run application, machine needs just a JRE (Java Runtime Environment)

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  jdk      Basic


 Q6. Can we compile and execute a Java class without main method ?Core Java
Ans. No without main method can not be executed it will throw an error illegal start of type. Main method is the entry point of application.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  compilation  main method      Basic


 Q7. What is JVM ?Core Java
Ans. JVM (Java Virtual Machine) is an abstract machine. It is a specification that provides runtime environment in which java bytecode can be executed.JVMs are available for many hardware and software platforms (i.e. JVM is platform dependent).Runtime Instance Whenever you write java command on the command prompt to run the java class, an instance of JVM is createdThe JVM performs following operation:Loads codeVerifies codeExecutes codeProvides runtime environment

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     memory management  jvm     Asked in 3 Companies      basic        frequent


 Q8. What is an execution engine within JVM ?Core Java
Ans. Execution engine contains interpreter and JIT compiler, which covert byte code into machine code.


 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  execution engine  compiler     Asked in 1 Companies


 Q9. What is Shutdown hook ?Core Java
Ans. Shutdown hook is a thread that is invoked before the JVM is shut down. we can use it perform resource cleaning task.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     shutdown hook  jvm

Try 1 Question(s) Test


Frequently asked in Alibaba (Based on 2 feedback)
 Q10. What is the best Memory setting for JVM ?Core Java
Ans. In Java JVM memory settings is done by use the arguments -Xms -Xmx. Use M or G after the numbers for indicating Megs and Gigs of bytes respectively. -Xms indicates the minimum and -Xmx the maximum.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  memory management  jvm best memory setting     Asked in 1 Companies      intermediate


 Q11. How can we find the memory usage of JVM from Java code?Core Java
Ans. Using Runtime object.

Runtime runtime = Runtime.getRuntime();

runtime.totalMemory();
runtime.freeMemory();

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm  memory management        rare


 Q12. How can one determine if JVM is 32-bit or 64-bit from Java Program ?Core Java
Ans. There is a Java system property "sun.arch.data.model" that can tell if JVM is 32 bit of 64 bit

System.getProperty("sun.arch.data.model") can be used to get that property.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     jvm      intermediate        rare


 Q13. What are the disadvantages of running multiple apps in single JVM ?Core Java
Ans. 1. Issue with Jar and ClassPath Conflicts

2. Killing JVM will terminate all applications

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     JVM     Asked in 1 Companies


 Q14. Can I import same package/class twice? Will the JVM load the package twice at runtime?Core Java
Ans. One can import the same package or same class multiple times. Neither compiler nor JVM complains wil complain about it. And the JVM will internally load the class only once no matter how many times you import the same class.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   import   jvm   advanced     Asked in 1 Companies      intermediate        rare


 Q15. Different types of memory used by JVM ?Core Java
Ans. Class , Heap , Stack , Register , Native Method Stack.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   memory   advanced   architecture   technical architect     Asked in 1 Companies      intermediate        frequent

Try 5 Question(s) Test


 Q16. What is a class loader ? What are the different class loaders used by JVM ?Core Java
Ans. Part of JVM which is used to load classes and interfaces.

Bootstrap , Extension and System are the class loaders used by JVM.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   class loaders  classloaders   jvm   java memory management   advanced     Asked in 3 Companies


 Q17. Explain java.lang.OutOfMemoryError ?Core Java
Ans. This Error is thrown when the Java Virtual Machine cannot allocate an object because it is out of memory, and no more memory could be made available by the garbage collector.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   exceptions   jvm   outofmemoryerror     Asked in 1 Companies


Frequently asked to fresh graduates.
 Q18. Is JVM, a compiler or interpretor ?
Ans. Its an interpretor.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   compiler   interpretor      basic        frequent


 Q19. Difference between loadClass and Class.forName ?
Ans. loadClass only loads the class but doesn't initialize the object whereas Class.forName initialize the object after loading it.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   class loaders   jvm   advanced


 Q20. Which kind of memory is used for storing object member variables and function local variables ?
Ans. Local variables are stored in stack whereas object variables are stored in heap.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   stack memory   heap memory      expert


 Q21. Why do member variables have default values whereas local variables don't have any default value ?
Core Java
Ans. member variable are loaded into heap, so they are initialized with default values when an instance of a class is created. In case of local variables, they are stored in stack until they are being used.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   variables   stack memory   heap memory   default values      expert


 Q22. Why Java don't use pointers ?
Ans. Pointers are vulnerable and slight carelessness in their use may result in memory problems and hence Java intrinsically manage their use.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   pointers      intermediate


 Q23. Do we need to import java.lang package ?Core Java
Ans. No, It is loaded by default by the JVM.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   java.lang.package   yes-no


Advanced level question. Recently asked in few Indian service companies ( Based on 3 inputs )
 Q24. What are various types of Class loaders used by JVM ?Core Java
Ans. Bootstrap - Loads JDK internal classes, java.* packages.

Extensions - Loads jar files from JDK extensions directory - usually lib/ext directory of the JRE

System - Loads classes from system classpath.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   class loaders   bootstrap   extensions   system  classloaders   advanced   technical lead   technical architect     Asked in 7 Companies


 Q25. How are classes loaded by JVM ?Core Java
Ans. Class loaders are hierarchical. The very first class is specially loaded with the help of static main() method declared in your class. All the subsequently loaded classes are loaded by the classes, which are already loaded and running.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   class loaders  classloaders     Asked in 1 Companies


 Q26. Difference between static vs. dynamic class loading?Core Java
Ans. static loading - Classes are statically loaded with Java new operator.

dynamic class loading - Dynamic loading is a technique for programmatically invoking the functions of a class loader at run time.

Class.forName (Test className);

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   class loaders  classloaders   static class loading   static loading   dynamic class loading   dynamic loading     Asked in 2 Companies      expert        frequent


 Q27. What are strong, soft, weak and phantom references in Java ?Core Java
Ans. Garbage Collector wont remove a strong reference.

A soft reference will only get removed if memory is low.

A weak reference will get removed on the next garbage collection cycle.

A phantom reference will be finalized but the memory will not be reclaimed. Can be useful when you want to be notified that an object is about to be collected.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   memory management   jvm   garbage collections   references   strong reference   soft reference   weak reference   phantom reference   architecture     Asked in 2 Companies


 Q28. Name few tools for probing Java Memory Leaks ?
Ans. JProbe, OptimizeIt

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   tools   jvm   memory management   memory leaks   jprobe   optimeit   architecture   technical lead


 Q29. Which memory areas does instance and static variables use ?Core Java
Ans. instance variables and objects are stored on heap and the references are stored on stack whereas static variables are stored in the method area of heap.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   memory   heap   stack

Try 2 Question(s) Test


 Q30. What is PermGen or Permanent Generation ?Core Java
Ans. The memory pool containing all the reflective data of the java virtual machine itself, such as class and method objects. With Java VMs that use class data sharing, this generation is divided into read-only and read-write areas. The Permanent generation contains metadata required by the JVM to describe the classes and methods used in the application. The permanent generation is populated by the JVM at runtime based on classes in use by the application. In addition, Java SE library classes and methods may be stored here.

 Help us improve. Please let us know the company, where you were asked this question :   

   Like         Discuss         Correct / Improve     java   jvm   memory management   permgen   permanent generation   advanced   architecture     Asked in 9 Companies      expert


next 30

Help us and Others Improve. Please let us know the questions asked in any of your previous interview.

Any input from you will be highly appreciated and It will unlock the application for 10 more requests.

Company Name:
Questions Asked: