473,405 Members | 2,300 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,405 developers and data experts.

Discuss your understanding of the Java platform.

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

Answer:
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.

Analysis:
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.

Expansion:
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.
May 18 '23 #1
0 4612

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

Similar topics

20
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 programming platform. My evaluation has shown:...
9
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 determine what is the best platform i should use...
0
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 smartphones, where J2ME has become the de facto...
133
by: Gaurav | last post by:
http://www.sys-con.com/story/print.cfm?storyid=45250 Any comments? Thanks Gaurav
14
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# can be run on a Unix or Mac machine. If this...
25
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 development on Linux. However, I've had some...
1
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, apache tomcat 5.5, freemarker and mysql. can i know...
3
by: datttanand | last post by:
How to write the main function in java script? such as in vb script sub main end sub
63
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 you think will be a better transition for a Python...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.