What is programming
Programming is to let the computer to solve a problem and use a programming language to write program code, and finally get the result of the process.
In order for the computer to understand the intention of man, man must tell the thought, method and means of the problem to be solved to the computer in a form that the computer can understand, so that the computer can work step by step according to the instructions of man and complete a specific task. This process of communication between humans and computers is called programming.
2. What is Java
Java is an object-oriented programming language, not only absorb the advantages of C++ language, but also abandon C++ difficult to understand multiple inheritance, Pointers and other concepts, so Java language has powerful and easy to use two characteristics. As a representative of static object-oriented programming languages, Java language has implemented object-oriented theory well, allowing programmers to do complex programming in an elegant way of thinking.
3. Three major versions after JDK1.5
Java SE (J2SE, Java 2 Platform Standard Edition, Standard Edition) Java SE was formerly known as J2SE. It allows the development and deployment of Java applications for use in desktop, server, embedded, and real-time environments. Java SE contains classes that support Java Web services development and provide the foundation for Java EE and Java ME. Java EE (J2EE, Java 2 Platform Enterprise Edition, Enterprise Edition) Java EE was formerly known as J2EE. The Enterprise version helps develop and deploy portable, robust, scalable, and secure server-side Java applications.
Java EE is built on Java SE and provides Web services, component models, management and communication apis that can be used to implement enterprise-level Service-oriented Architecture (SOA) and Web2.0 applications. In February 2018, Eclipse announced the official change of the name of Java ee to JakartaEEJava ME (J2ME, Java 2 Platform Micro Edition, Micro Edition). Java ME was formerly known as J2ME.
Java ME provides a robust and flexible environment for applications running on mobile and embedded devices, such as cell phones, PDAs, TV set-top boxes, and printers. Java ME includes a flexible user interface, a robust security model, a number of built-in network protocols, and rich support for both networked and offline applications that can be downloaded dynamically. Applications based on the JavaME specification can be written once for many devices and can take advantage of the native capabilities of each device.
4, the relationship between JVM, JRE and JDK
JVM: A Java Virtual Machine is a Java Virtual Machine. Java programs need to run on the Virtual Machine. Different platforms have their own VMS, so the Java language can be implemented cross-platform.
JRE: The Java Runtime Environment contains core libraries required by Java VMS and Java programs. The core class library is mainly java.lang package: contains essential system classes for running Java programs, such as basic data types, basic mathematical functions, string processing, threading, exception handling classes, etc. The system loads this package by default. If you want to run a developed Java program, you only need to install JRE on your computer.
JDK: The Java Development Kit is provided for Java developers, which contains Java Development tools, including the JRE. So with the JDK installed, there is no need to install the JRE separately. The development tools: compilation tool (javac.exe), packaging tool (jar.exe) and so on.
JVM&JRE & JDK diagram
5. What is cross-platform? How does it work
Cross-platform means that programs written in the Java language can run on multiple system platforms once compiled.
Implementation principle: Java programs run on the system platform through Java VIRTUAL machine. As long as the system can install the corresponding Java VIRTUAL machine, the system can run Java programs.
6. What are the features of the Java language
Simple and easy to learn (the Syntax of the Java language is close to THAT of C and C++)
Object oriented (encapsulation, inheritance, polymorphism)
Platform independence (Java Virtual machine implementation platform independence)
Network programming support and convenience (the Java language itself was designed to simplify network programming)
Support for multithreading (a mechanism that allows applications to execute multiple tasks in parallel at the same time)
Robustness (Java language’s strong typing mechanism, exception handling, automatic garbage collection, etc.)
security
7. What is bytecode? What are the biggest benefits of bytecode adoption
Bytecode: A file generated by Java source code compiled by the virtual machine compiler (that is, a file extended to.class) that is not oriented to any particular processor, but only to the virtual machine.
Advantages of using bytecode: Java language solves the problem of low efficiency of traditional interpreted languages to a certain extent by means of bytecode, while retaining the characteristics of portability of interpreted languages. So Java programs run more efficiently, and because bytecode is not specific to a particular machine, Java programs can run on many different machines without recompiling.
Consider compilers and interpreters in Java: Java introduced the concept of the virtual machine, a virtual machine with an abstract layer between the machine and the compiler. This virtual machine provides a common interface for compilers on any platform. The compiler simply faces the virtual machine, generates code that the virtual machine understands, and then the interpreter translates the virtual machine code into system-specific machine code for execution. In Java, this code for virtual machine understanding is called bytecode (that is, files that extend to.class) and is not oriented to any particular processor, just to the virtual machine. The interpreter for each platform is different, but the virtual machine implemented is the same. After compiler to compile the Java source code into the bytecode, byte code execution is interpreted by a virtual machine, virtual machine will each to execute bytecode to interpreter, the interpreter translated into machine code on specific machines, and then run on a particular machine, this is the characteristics of the above mentioned Java compilation explanation and interpretation.
Java source code -- -- -- -- -- -- -- -- > > compiler JVM executable Java bytecode (that is, the virtual instruction) -- -- -- -- -- -- -- -- > > JVM JVM interpreter -- -- -- -- > machine executable binary machine code -- -- -- -- > program is running.Copy the code
What is the main class of a Java program? What is the difference between the main class of an application and a applet?
A program can have more than one class, but only one class can be the main class. In A Java application, this main class is the class that contains the main() method. In Java applets, the main class is a subclass that descends from the system class JApplet or Applet. The main class of the application is not required to be public, but the main class of the applet must be public. The main class is the entry point for Java program execution.
What are the differences between Java applications and applets?
Simply put, the application starts from the main thread (the main() method). Applets do not have a main method, but instead run embedded in a browser page (init() or run() is invoked), similar to flash mini-games.
10. The difference between Java and C++
I know many people have never learned C++, but the interviewer likes to compare Java with C++. No way!! Even if you haven’t learned C++, write it down!
Both are object-oriented languages that support encapsulation, inheritance, and polymorphism
Java does not provide Pointers to access memory directly; program memory is more secure
Java classes are single inheritance, C++ supports multiple inheritance; Although Java classes cannot be multiinherited, interfaces can.
Java has automatic memory management mechanisms that do not require programmers to manually free unwanted memory
Oracle JDK and OpenJDK
-
Oracle JDK versions will be released every three years, while OpenJDK versions will be released every three months;
-
The OpenJDK is a reference model and is fully open source, whereas the Oracle JDK is an implementation of OpenJDK and is not fully open source;
-
The Oracle JDK is more stable than the OpenJDK. The OpenJDK and Oracle JDK have nearly the same code, but the Oracle JDK has more classes and some bug fixes. Therefore, if you want to develop enterprise/business software, I recommend you choose the Oracle JDK because it is thoroughly tested and stable. In some cases, some people have mentioned that they may encounter many application crashes while using OpenJDK, but simply switch to the Oracle JDK to solve the problem;
-
The Oracle JDK provides better performance than the OpenJDK in terms of responsiveness and JVM performance;
-
The Oracle JDK does not provide long-term support for upcoming releases; users must update to the latest version each time to get support;
-
The Oracle JDK is licensed under the binary code License, while the OpenJDK is licensed under the GPL V2 license.