Recently, I received a lot of complaints from students who are looking for jobs. After more than ten days of painstaking preparation, I finally got an interview opportunity, but I failed to answer the question “What are the eight basic data types?” This is the most basic problem, so the loss of offer, missed opportunities.

What? Can’t answer any of the eight basic data types? Classmate, you need to review this foundation.

Java basic tutorial _ beginners _ basic consolidation

The interviewer’s mind is unpredictable, who knows what kind of weird questions will be asked, probably many students are focused on IOC, AOP, database tuning and the preparation of various framework principles, but ignore the simplest, most basic questions.

Having learned from the past, in order to avoid other students in this situation. Xiaobian specially sorted out some basic Java questions that appeared frequently in the interview, hoping to help students quickly recall the basic Knowledge points in Java, successfully get the offer, and find their own satisfactory job.

The following summary of the problem, all from Java300 set, the foundation is not too solid students, must learn oh ~

Java300 set

1. What is JVM? What is the JDK? What is JRE?

  • JVM: JVM is short for Java Virtual Machine (Java Virtual Machine). It is the core part of the entire Java implementation cross-platform. All Java programs are first compiled into.class class files, which can be executed on the Virtual Machine.
  • JRE: JRE stands for Java Runtime Environment. A class file cannot be executed by a JVM alone, because the JVM needs to call lib to interpret the class. In the JDK installation directory, you can find the JRE directory. There are two folders, bin and lib. Bin is the JVM, lib is the library that the JVM needs to work, and the JVM and lib together are called JRE.
  • JDK: THE JDK stands for Java Development Kit. Everyone learning Java has a JDK installed on their machine, so let’s take a look at the JDK installation directory. Under the directory there are six folders, a SRC class library source zip, and several other declaration files. The folders that really work when Java is running are bin, include, lib, and JRE.

Now we can see the relationship that the JDK contains the JRE, and the JRE contains the JVM.

The relationship between JDK,JRE, and JVM is summarized as follows:

JDK is a development kit used for Java program development, which also has the Java runtime environment JRE. JRE is the runtime environment that Java programs need to run, which means that if you only run Java programs instead of developing them, you can run existing Java programs by installing the JRE. Both JDk and JRE contain Java virtual machine JVMS, and Java virtual machines contain interpreters and classloaders for many application classes.

Java three annotation types

1) Single-line comments, using “//”. Only one line of code can be commented.

/… /… /… / “, can comment multiple lines of code, which does not allow nesting.

/**… * / “way.

3. Eight basic data types and their number of bytes

I ++ and ++ I

Thing in common:

  1. I ++ and ++ I are both increments by 1, which is the same thing as I = I +1
  2. If I ++,++ I is a separate statement, there is no difference between the two
  3. I ++ and ++ I are used only for variables. 5++ and ++5 will report an error because 5 is not a variable.

Difference:

If I ++,++ I are not a single statement, they are different.

I++ : evaluates first and then increments by 1. Such as:

++ I: increment 1 before calculation. Such as:

5, if multi-branch statement and switch multi-branch statement similarities and differences

Similarities:

Both are branch statements that deal with more than one case.

Differences:

Switch is more suitable for multi-branch situation, that is, there are many cases to judge and deal with, the judgment condition type is single, there is only one entrance, after the branch execution (if there is no break jump), execute without judgment;

If — elseif– else multiple branches are mainly applicable to branch structures with fewer branches. The judgment type is not single. As long as one branch is executed, the following branches are not executed.

Switch is equivalent judgment (such as >= <= is not allowed), while if is equal or interval. If is widely used.

6. Differences between while and do-while loops

While evaluates before executing, the first time it evaluates to false, and the loop body does not execute once

Do while perform the operation at least once.

If the while loop is first judged true, there is no difference between the two loops.

7. The role of break and continue

Break: Terminates the current loop and exits the current loop body.

Break can also exit the switch statement

Continue: subsequent statements in the body of the loop are not executed, but the loop does not end, and the condition continues (for loop also i++). Continue simply ends the loop.

The relationship between classes and objects

A class is an abstraction of an object, and an object is a concrete instance of a class. Classes are abstract and take up no memory, while objects are concrete and take up storage. A class is a blueprint for creating an object. It is a software template that defines methods and variables to be included in a particular type of object.

Class and object are like the relationship between drawing and object, mold and casting.

For example, a human being is a concept, a human being has properties such as height and weight. Humans can eat, talk and so on.

Xiao Ming is a specific person, that is, an example. His attributes are 200cm in height and 180kg in weight. He ate a bowl of white rice and said “12345”.

The difference between procedural and object oriented

metaphor

Process-oriented is egg-fried rice, object-oriented is covered rice. The advantage of covered rice is the separation of “rice” and “dish”, thus improving the flexibility of making covered rice. If you are not satisfied with the food, change the food. With software engineering terminology is “maintainability” is better, “meal” and “dish” coupling degree is relatively low.

The difference between

Different programming ideas: process-oriented function development to achieve the function is given priority to, and object-oriented to first abstract out the class, attribute and method, and then through the instantiation of the class, the implementation of the method to complete the function.

Encapsulation: Both encapsulate, but process-oriented encapsulates functionality, while object-oriented encapsulates data and functionality.

Object orientation has inheritance and polymorphism, while process orientation has no inheritance and polymorphism, so the advantage of object orientation is obvious.

The difference between method overloading and method overwriting

These ten interview questions are important, and I’ve compiled more than 600 of them, covering all aspects of Java. The basic part alone has more than 300 lines, accounting for half. So, basics are important, class. Let’s go over the basics.

Java basic knowledge consolidation