Prev Next

Java / JDK, JRE, JVM, JIT

1. Architectural-neutral. 2. What is High level language? 3. What is Java? 4. Three flavors of Java. 5. Difference between JDK, JRE and JVM. 6. Interpreted. 7. Features of Java. (or) Java buzzwords. 8. Java is object oriented. 9. Is Java a WORA? 10. Java is Simple. 11. Java is Platform independent. 12. How many types of memory areas are allocated by JVM? 13. What is the latest version of Java? 14. What is Write Once, Run Anywhere (WORA)? 15. What is a Platform? 16. Is Java a pure/fully object oriented language? 17. Secured. 18. What is bytecode? 19. Portable. 20. Robust. 21. Dynamic. 22. High-performance. 23. Multithreaded. 24. Distributed. 25. What is classloader? 26. Types of classloader. 27. What is Heap space in Java? 28. Default heap size in Java. 29. What is Java Memory Model? 30. What are the new features introduced in Java 8? 31. Difference between EAR, JAR and WAR file in J2EE. 32. Explain memory leak in Java. 33. How Garbage collection works in Java? 34. What are the GC roots in Java? 35. Types of memory leaks in Java. 36. How do you diagonise memory leaks in Java? 37. Difference between Stack and Heap memory in Java. 38. Does Java garbage collector cleans both heap and stack memory? 39. Why garbage collection is required in Java? 40. How GC does not affect Java program's performance? 41. Different categories of GC algorithm. 42. List the available GC algorithms in Java. 43. What is the default GC collector in Java 8? 44. What are types of reference in Java? 45. Explain strong reference type in Java. 46. Explain weak reference type in Java. 47. Explain Serial Garbage Collector in Java. 48. Explain Parallel Garbage Collector in Java. 49. Explain CMS Garbage Collector in Java. 50. Explain G1 Garbage Collector in Java. 51. What is soft reference in Java? 52. What is phantom reference in Java? 53. Explain the javap command in Java. 54. What is PermGen in Java? 55. What is metaspace in JDK 1.8? 56. Explain the usage of MetaspaceSize parameter in Java 8. 57. Difference between permgen and metaspace in Java. 58. New features introduced in Java 1.7. 59. How do I load Jars dynamically at runtime? 60. What is synthetic construct in Java? 61. New changes introduced in Java 9. 62. What is jshell tool in Java 9? 63. Difference between Java.exe and Javaw.exe. 64. What is Nashorn in Java8? 65. How do I debug to see when class is loaded in jvm? 66. Mention Java features designed to improve application security. 67. Mention few security Libraries that Java platform supports. 68. Mention few advanced coding concepts in Java for security considerations.

1. Architectural-neutral.

Java programs are compiled to generate byte-code which is .class file. This byte-code files are interpreted by the architecture specific JVM to execute that makes java programs run in any type of hardware.

Read full answer

2. What is High level language?

High level languages(HLL) are languages that has less complexity and easy to understand, as the syntax are close to human language and it abstracts the machine language.

Read full answer

3. What is Java?

Java is a high-level programming language and object oriented. It was developed by Sun Micro systems, initially released in 1995.

Read full answer

4. Three flavors of Java.

ME(Micro Edition) for mobile, SE(Standard Edition) for desktops, and EE(Enterprise edition) for enterprise.

Read full answer

5. Difference between JDK, JRE and JVM.

JVM JVM is Java Virtual Machine, it provides the runtime environment in which java bytecode can be executed. JVMs are available for many hardware and software platforms (so JVM is platform dependent). JRE JRE is Java Runtime Environment. It is the implementation of JVM. JRE doesn't have Javac com...

Read full answer

6. Interpreted.

The Java compiler generates byte-codes, rather than native machine code. To run a Java program, you use the Java interpreter to execute the compiled byte-codes. Java byte-codes provide an architecture-neutral object file format. The code is designed to transport programs efficiently to multiple p...

Read full answer

7. Features of Java. (or) Java buzzwords.

There are 12 buzzwords. Simple. Object-Oriented. Platform independent. Secured. Robust. Architecture neutral. Portable. Dynamic. Interpreted. High Performance. Multithreaded. Distributed.

Read full answer

8. Java is object oriented.

Java is object based as we cannot create any program without creating a class.

Read full answer

9. Is Java a WORA?

10. Java is Simple.

Java is an easy to understand and simple to learn.

Read full answer

11. Java is Platform independent.

JAVA supports WORA which make it run across different platform/operating system.

Read full answer

12. How many types of memory areas are allocated by JVM?

Many types: Class(Method) Area, Heap, Stack, Program Counter Register, Native Method Stack.

Read full answer

13. What is the latest version of Java?

Java 10 released on March 20, 2018.

Read full answer

14. What is Write Once, Run Anywhere (WORA)?

WORA refers to the ability of a computer program to run across any operation system or platform.

Read full answer

15. What is a Platform?

Platform refers to any hardware/software environment under which a program runs.

Read full answer

16. Is Java a pure/fully object oriented language?

Java has primitive data types which are not objects, so Java is considered as not fully object oriented language. However Java could be considered as fully object oriented language as it has wrapper classes for its primitive types.

Read full answer

17. Secured.

Java is secured for developing application due to many of security features that includes, Byte-code verification before execution, Run time security checks, Immutable classes (String for e.g.)

Read full answer

18. What is bytecode?

Bytecode is a highly optimized set of instructions, low level language and non-executable code. The platform specific JVM interprets bytecode to run the program.

Read full answer

19. Portable.

Being platform independent and architecture neutral, Java application developed in one enviroment can be deployed to different platform and executed using compliant JVM. Java application developed for Desktops(SE) are fully portal where Java EE has EJB which makes it less portal.

Read full answer

20. Robust.

highly supported language and portable, Strongly typed language, Memory Management, Garbage Collection, Exception Handling, No pointers.

Read full answer

21. Dynamic.

Java was designed to adapt to an evolving/changing environment. Even after binaries have been released, they can adapt to a changing environment. Java loads in classes as they are needed, even from across the network It defers many decisions (like object layout) to runtime, which solves many of t...

Read full answer

22. High-performance.

Although Java is an interpreted language, it is faster than other interpreted languages. JITC ( Just in Time compilation) is one such feature that enables Java as high-performance language (HPC).

Read full answer

23. Multithreaded.

Java is inherently multi-threaded. A single Java program can have many different threads executing independently and continuously.

Read full answer

24. Distributed.

Java application can be distributed and the implementation of variable protocols enables effective communication.

Read full answer

25. What is classloader?

The classloader, a subsystem of JVM, is used to load classes and interfaces.

Read full answer

26. Types of classloader.

There are many types of classloaders e.g. Bootstrap, Extension, System, Plugin.

Read full answer

27. What is Heap space in Java?

Java Virtual Machine(JVM) gets some memory from the underlying operating system to run any java program. This memory is referred as Java heap. Heap in Java located at bottom of address space and move upwards. When an object is created using new operator or by any other means object is allocated m...

Read full answer

28. Default heap size in Java.

Default maximum heap space is 1/2 of physical memory of size upto 192 bytes and 1/4th of physical memory for size upto 1Gig. So for 1Gig machine maximum heap size is 256MB 2.maximum heap size will not be used until program creates enough object to fill initial heap space which will be much lesser...

Read full answer

29. What is Java Memory Model?

The Java memory model specifies how the Java virtual machine works with the computer's memory (RAM).

Read full answer

30. What are the new features introduced in Java 8?

Lambda Expressions, Interface Default and Static Methods, Method Reference, Parameters Name, Optional feature, Streams, and Concurrency.

Read full answer

31. Difference between EAR, JAR and WAR file in J2EE.

J2EE defines three types of archives. Java Archive (JAR) A JAR file encapsulates one or more Java classes, a manifest, and a descriptor. JAR files are the lowest level of archive. JAR files are used in J2EE for packaging EJBs and client-side Java Applications. Web Archive (WAR) A WAR files are si...

Read full answer

32. Explain memory leak in Java.

Memory leak in Java refers to a situation where some objects are not used by the application any more, but GC fails to recognize them as unused. As a result, these objects remain in memory indefinitely, reducing the amount of memory available to the application.

Read full answer

33. How Garbage collection works in Java?

Every Java object tree must have one or more root objects. As long as the application can reach those roots, the whole tree is reachable. There are some objects which are considered ?important? by GC. These are called GC roots and are (almost) never discarded. They are, for example, currently exe...

Read full answer

34. What are the GC roots in Java?

There are 4 different kinds of GC roots in Java. Local variables, Active Java threads, Static variables, and JNI References.

Read full answer

35. Types of memory leaks in Java.

OutOfMemoryError is one of the symptom to be diagnosed as it could lead to memory leaks. Application may crash without issuing OutOfMemoryError.

Read full answer

36. How do you diagonise memory leaks in Java?

Identify symptoms, Enable verbose garbage collection using -verbosegc argument, Enable profiling, Analyze the trace.

Read full answer

37. Difference between Stack and Heap memory in Java.

The main difference between heap and stack is that stack memory is used to store local variables and function call while heap memory stores objects in Java. Each Thread in Java has its own stack whose size can be specified using -Xss JVM parameter, similarly, you can also specify heap size of Jav...

Read full answer

38. Does Java garbage collector cleans both heap and stack memory?

GC sweeps heap memory only. Usually, stack memory is collected automatically when the execution path reaches the end of the scope.

Read full answer

39. Why garbage collection is required in Java?

Garbage collection relieves programmers from the burden of freeing allocated memory. GC helps ensure program integrity. Garbage collection is an important part of Java's security strategy.

Read full answer

40. How GC does not affect Java program's performance?

Because Java's garbage collector runs in its own thread, in most cases, it will run transparently alongside the execution of a program.

Read full answer

41. Different categories of GC algorithm.

GC algorithms can be divided into 3 categories: sweeping, compacting and copying.

Read full answer

42. List the available GC algorithms in Java.

The Serial GC recommended for client-style applications that do not have low pause time requirements. The Parallel GC - use when the throughput matters. The Mostly-Concurrent GC (also known as Concurrent Mark-Sweep GC(CMS)) - use when the latency matters. The Garbage First GC (G1) - new GC algori...

Read full answer

43. What is the default GC collector in Java 8?

Parallel GC. It is faster compared to the other algorithms.

Read full answer

44. What are types of reference in Java?

Java provides 4 different types of Reference Objects: strong , weak , soft and phantom .

Read full answer

45. Explain strong reference type in Java.

Strong reference : This reference is something that we use daily while writing the code. Any object in the memory which has active strong reference is not eligible for garbage collection. For example String s = "abc" , reference variable s has strong reference to String object "abc". Any object w...

Read full answer

46. Explain weak reference type in Java.

Weak Reference are represented using java.lang.ref.WeakReference class and you can create Weak Reference by using following code. WeakReference weakBuilder = new WeakReference(builder); A weak reference is a reference that isn't strong enough to force an object to re...

Read full answer

47. Explain Serial Garbage Collector in Java.

Serial garbage collector works by holding all the application threads. It is designed for the single-threaded environments. It uses just a single thread for garbage collection. The way it works by freezing all the application threads while doing garbage collection may not be suitable for a server...

Read full answer

48. Explain Parallel Garbage Collector in Java.

Parallel garbage collector also called as throughput collector, is the default garbage collector of the JVM. Unlike serial garbage collector, this uses multiple threads for garbage collection. Similar to serial garbage collector this also freezes all the application threads while performing garba...

Read full answer

49. Explain CMS Garbage Collector in Java.

Concurrent Mark Sweep (CMS) garbage collector uses multiple threads to scan the heap memory to mark instances for eviction and then sweep the marked instances. CMS garbage collector holds all the application threads in the following two scenarios only, While marking the referenced objects in the ...

Read full answer

50. Explain G1 Garbage Collector in Java.

G1 garbage collector is used for large heap memory areas. It separates the heap memory into regions and does collection within them in parallel. G1 also does compacts the free heap space on the go just after reclaiming the memory. But CMS garbage collector compacts the memory on stop the world (S...

Read full answer

51. What is soft reference in Java?

A soft reference is exactly like a weak reference, except that it is less eager to throw away the object to which it refers. An object which is only weakly reachable (the strongest references to it are WeakReferences) will be discarded at the next garbage collection cycle, but an object which is ...

Read full answer

52. What is phantom reference in Java?

A phantom reference is quite different than either SoftReference or WeakReference. Its grip on its object is so tenuous that you can't even retrieve the object -- its get() method always returns null. The only use for such a reference is keeping track of when it gets enqueued into a ReferenceQueu...

Read full answer

53. Explain the javap command in Java.

The javap command disassembles one or more class files. javap prints out the package, protected, and public fields and methods of the classes passed to it. javap prints its output to stdout. You may use it to find out what methods are available for a class if you don?t have the source code that w...

Read full answer

54. What is PermGen in Java?

PermGen stands for permanent generation space. PermGen is a 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...

Read full answer

55. What is metaspace in JDK 1.8?

PermGen has been completely replaced by MetaSpace in Java8, a native memory to store class meta-data information and that grows automatically. We don't encounter OutOfMemoryError in Java 1.8, PermSize and MaxPermSize arguments are ignored at the start-up of application. On the contrary these two ...

Read full answer

56. Explain the usage of MetaspaceSize parameter in Java 8.

Set MetaspaceSize to a value larger than the default, if you know that your applications needs more space for class data. Setting it to a larger size will avoid some number of GCs at startup.

Read full answer

57. Difference between permgen and metaspace in Java.

Metaspace auto increases its size by default (up to what the underlying OS provides), while PermGen always has a fixed maximum size.

Read full answer

58. New features introduced in Java 1.7.

1. Underscores Between Digits in Numeric Literals. int ten_million = 10_000_000; 2. Improved Type Inference for Generic Instance Creation using Diamond operator. Map> anagrams = new HashMap>(); // The above statement can be rewritten using Java Diamond op...

Read full answer

59. How do I load Jars dynamically at runtime?

Using URLClassLoader we can load the jar. URLClassLoader child = new URLClassLoader (myJarFile . toURL(), this . getClass() . getClassLoader()); Class classToLoad = Class . forName ( "net.javapedia.MyClass" , true, child); Method method = classToLoad . getDeclaredMethod ( "methodToCall" ); Object...

Read full answer

60. What is synthetic construct in Java?

Synthetic constructs are class, fields, and methods that are not defined in Java source code and created by the Java compiler while compiling. For switch statement, Java compiler creates a synthetic field that start with $, and also for the local classes which is required by the VM. Synthetic con...

Read full answer

61. New changes introduced in Java 9.

Allow @SafeVargs on private instance methods. Allow effectively final variables to be used as resources in the try-with-resources statement. Allow the diamond with anonymous classes if the argument type of the inferred type is denotable. Complete the removal of the underscore from the set of lega...

Read full answer

62. What is jshell tool in Java 9?

JDK 9 adds Read-Eval-Print Loop (REPL) functionality to the Java platform. The jshell tool provides an interactive command-line interface for evaluating declarations, statements, and expressions of the Java programming language. It facilitates prototyping and exploration of coding options with im...

Read full answer

63. Difference between Java.exe and Javaw.exe.

Java is the plain old java interpreter, you have a console window open all the time. Javaw is a wrapper around java that doesn't open a console window. java.exe pops up a console window. javaw.exe does not. If you expect text output, you'll need to use java.exe. If the application pops up its own...

Read full answer

64. What is Nashorn in Java8?

Nashorn is the new Javascript processing engine for the Java platform that shipped with Java 8. Until JDK 7, the Java platform used Mozilla Rhino for the same purpose as a Javascript processing engine.

Read full answer

65. How do I debug to see when class is loaded in jvm?

You may add the command line option -verbose:class to your Java process, this will display information about each class loaded. java -verbose:class

Read full answer

66. Mention Java features designed to improve application security.

Strong Data typing : The security concern here is that coding errors that would manifest at runtime in dynamically typed languages are resolve at compile time by strongly typed languages such as Java. Automatic memory management : Reduces the complexity of managing application memory and the rate...

Read full answer

67. Mention few security Libraries that Java platform supports.

Authentication and Access control : The platform provides libraries such as Java Authentication and Authorization Service (JAAS) and Java policies to ensure only authorized individuals can change application data. Protecting Data : Cryptographic controls (digital signature, message digests, ciphe...

Read full answer

68. Mention few advanced coding concepts in Java for security considerations.

Avoiding Strings for volatile secrets : Storing passwords in String objects increases the application risk profile since Strings will remain on the heap until garbage collection. Avoid Deserializing objects from untrusted sources : The serialization framework calls readObject() on each Serializab...

Read full answer

«
»

Comments & Discussions