472,328 Members | 1,007 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 472,328 developers and data experts.

Discuss your understanding of the Java platform.

1 Bit
Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct?

Java is an object-oriented language with two prominent features. First, it offers the ability to "write once, run anywhere," making it easy to achieve cross-platform capabilities. Second, Java incorporates garbage collection (GC) where a garbage collector automatically reclaims allocated memory, relieving programmers from the burden of manual memory management in most cases.

In our daily work, we come across JRE (Java Runtime Environment) or JDK (Java Development Kit). JRE includes the JVM (Java Virtual Machine), Java class libraries, and various modules. JDK can be considered as a superset of JRE, providing additional tools such as compilers and diagnostic utilities.

Regarding the statement "Java is interpreted," it is not entirely accurate. The Java source code we develop is first compiled into bytecode using Javac. During runtime, the bytecode is then interpreted by the interpreter embedded within the Java Virtual Machine (JVM) to produce the final machine code. However, popular JVMs like Hotspot JVM provided by Oracle JDK include a Just-In-Time (JIT) compiler. The JIT compiler dynamically compiles hot code into machine code at runtime. In this case, the execution becomes partially compiled rather than interpreted.

In fact, this question is quite general. The question itself is very open-ended and often tests multiple aspects, such as whether the understanding of basic knowledge is clear and whether the interviewee has a grasp of the main modules and operating principles of the Java platform, etc. Many interviewees may struggle with this kind of question and, feeling a bit nervous, may not know where to start and give a very brief answer.

For such general questions, you should try to demonstrate your deep and systematic thinking, as well as a comprehensive understanding of Java knowledge. You must avoid giving the impression to the interviewer that you know the facts but not the underlying reasons. After all, understanding the basic components and mechanisms is the foundation for many tasks in daily work, such as problem diagnosis and performance tuning. I believe no hiring party would dislike an interviewee who "loves learning and thinking."

Even if you feel that your answer is not very comprehensive, there is no need to worry. Personally, I think it is normal to give somewhat one-sided answers to these kinds of general questions. Most experienced interviewers will not easily draw conclusions about an interviewee based on one question alone. They usually try to guide the interviewee to showcase their true level. This type of question is just a warm-up, and interviewers often expand on related questions based on your answer.

When it comes to understanding the Java platform, we can briefly discuss it from various aspects. For example, Java language features, including generics, lambdas, and other language features. We can also talk about the core class libraries, such as collections, IO/NIO, networking, concurrency, security, and other foundational libraries. It would be helpful to systematically summarize the commonly used libraries in our daily work before the interview, as it aids in on-the-spot performance.

Alternatively, we can discuss some basic concepts and mechanisms of the JVM, such as Java's class loading mechanism. We can delve into commonly used class loaders embedded in JDK versions (e.g., JDK 8), such as Bootstrap, Application, and Extension ClassLoaders. We can explore the general process of class loading, including loading, verification, linking, and initialization. Additionally, topics like custom class loaders can be discussed. Another area to explore is the basic principles of garbage collection and the most common garbage collectors, such as SerialGC, Parallel GC, CMS, G1, and understanding which workloads they are best suited for. These are expandable areas that I will cover in more detail in future columns.

Furthermore, we can touch upon the tools included in the JDK or other tools within the Java domain. These may include compilers, runtime environments, security tools, diagnostic and monitoring tools, and more. These essential tools ensure our daily work efficiency and can also be helpful when working on other language platforms, as many concepts can be applied analogously.

Some interviewers like to "dig deep" into specific questions because it is an effective way to further understand the extent of the candidate's knowledge. Let's delve a little deeper into this topic.

As we know, Java is typically divided into the compilation phase and the runtime phase. When we talk about Java compilation, it differs from C/C++. In the case of Java, the compilation by Javac produces bytecode in the ".class" file, which is not directly executable machine code. Java achieves its "write once, run anywhere" capability by using bytecode and the Java Virtual Machine (JVM) as a platform abstraction layer, shielding the details of the operating system and hardware.

During runtime, the JVM loads the bytecode using class loaders and interprets or compiles it for execution. As mentioned earlier, in mainstream Java versions such as JDK 8, there is a hybrid mode called "mixed mode" (-Xmixed), which combines interpretation and compilation. JVMs running in server mode, for example, perform thousands of invocations before gathering enough information for efficient compilation, while in client mode, the threshold is 1500 invocations. Oracle Hotspot JVM includes two different JIT compilers: C1, which corresponds to the client mode and is suitable for applications sensitive to startup speed, such as regular Java desktop applications, and C2, which corresponds to the server mode and is optimized for long-running server applications. The default is to use a technique called "Tiered Compilation" that employs both compilers. I won't delve into more JIT details at this point; it's not necessary to dive right in. I will cover the topic of Tiered Compilation in more detail later on.

Moreover, Oracle JDK supports the collaboration of tiered compilation and AOT. They are not mutually exclusive options. AOT is not limited to just one approach; there have been third-party tools in the industry (such as GCJ and Excelsior JET) that provide similar functionality.

Furthermore, as a powerful platform, the JVM is not limited to running only Java programs. Essentially, any bytecode that is compliant can run on the JVM. Java itself provides convenience for this, and we can see a wide range of JVM languages such as Clojure, Scala, Groovy, JRuby, Jython, and more, actively used in different scenarios.
1 Week Ago #1
0 2306

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Ilias Lazaridis | last post by:
" A cooperation between Sun Microsystems and IBM&Co. in conjunction with liberal & high evolutive communities would result in an nearly unbeatable...
by: CY FOK | last post by:
Hi I am planning to open a software company to develop client-server apps and web applications for my client. Now, i am in a difficult situation to...
by: asj | last post by:
luke: BORRRRRRRRING......the most interesting initiatives are happening on the client side - in small wireless devices such as cellphones and...
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
by: John Salerno | last post by:
Bear with me, but I've been reading a lot about how the .NET languages are platform independent, and I assume this means a program written in C#...
by: redefined.horizons | last post by:
I've traditionally been a Java developer, although I play around with LISP. I recently migrated to Linux and I was exploring Mono as an option for...
by: sakurasyi | last post by:
hai there... i have some question.. 1. can anyone know what are the differences between java SE, java EE and java ME? 2. i have use jdk 1.5,...
by: datttanand | last post by:
How to write the main function in java script? such as in vb script sub main end sub
by: s0suk3 | last post by:
I've been programming Python for a couple of years now. Now I'm looking to move on to either C++ or Java, but I'm not sure which. Which one do...
by: concettolabs | last post by:
In today's business world, businesses are increasingly turning to PowerApps to develop custom business applications. PowerApps is a powerful tool...
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
by: CD Tom | last post by:
This happens in runtime 2013 and 2016. When a report is run and then closed a toolbar shows up and the only way to get it to go away is to right...
by: CD Tom | last post by:
This only shows up in access runtime. When a user select a report from my report menu when they close the report they get a menu I've called Add-ins...
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge...
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.