1. JDK, JRE, JVM

① Java Development Kit: Java Development Kit

② JRE: Java Runtime Environment

③ JVM: Java Virtual Machine Java VIRTUAL Machine

2. Briefly describe the process of compiling and running Java programs

The Java compiler translates Java source code into JVM executable code called bytecode. After the source file is created, the program is first compiled into a “. Class “file.

② After the compiled Java program gets the. Class file, run the command Java to start a JVM process, find the entry to the main function, and start executing the main function.

3. Eight basic data types and byte sizes

1 byte 8 bits

(2) short 16

(3) int 32 bits

(4) long, 64

(5) float 32 bits

6 double 64 bits

All landowners Boolean one

Today char 16

4. Print the multiplication table using nested for loops.

public class Multiplication {

public static void main(String[] args) {

for (int i = 1; i<=9; i++){

for(int j = 1; j<=i; j++){

System.out.print(j+”*”+i+”=”+i*j+” “);

}

System.out.println();

}

}

}

1. The difference between value passing and reference passing

(1) Value transfer: value transfer is to copy the value of the transfer, and then transfer the value of the copy, the transfer process before and after does not change the size of the original value;

② Reference transfer: reference transfer is to transfer the address of the value, the transfer process will change the size of the original value.

What is method overloading

Method overloading is the definition of multiple methods with the same name in a class, but each method is required to have a different type or number of parameters.

3. Four types of access control characters are described

① Private: a member declared as Private can only be accessed by other members of the current class and cannot be seen outside the class.

(2) Default (package access permission) : If a class or a member of a class does not have an access control character, it will get the default access permission, which can be accessed by all classes in the same package.

③ Protected: Members declared Protected can be accessed by other classes in the same package or by subclasses in different packages.

(4) Public: Members declared as Public can be accessed by all classes in the same package or different packages. That is, the Public access modifier can make the features of a class common to any class.

Write eight basic data types that provide corresponding wrapper classes

1 byte byte bytes

② Short short

③ int Integer Specifies the Integer

④ Long long

⑤ Char Character type

⑥ Float float single-precision floating point type

⑦ Double double precision floating point type

⑧ Boolean Boolean type

5. What is packing and unpacking

(1) Packing: refers to the conversion of basic type data values into corresponding encapsulated objects, that is, the data in the stack encapsulated into objects stored on the stack;

(2) Unpacking: Unpacking is the reverse process of packing. It is the process of converting the encapsulated object into the data value of basic type and storing the data value in the heap in the stack.

6. The difference between String and StringBuilder

1) String String of innovation to build strings are immutable, if change the value of the String variable is in memory to create a new String, the String variable will refer to the newly created String address, and the original String in memory still exists and content is constant, until the Java garbage collection system to be destroyed;

StringBuilde creates a mutable string. StringBuilder does not implement thread-safety, so it performs better.

Write a PointDemo class and provide a distance(Point P1,Point P2) method for counting

Calculates the distance between two points, instantiates two concrete Point objects and displays the distance between them

public class PointDemo {

public void distance(Point p1 ,Point p2 ){

double dist =0;

double a = Math.pow((p1.getX()-p2.getX()),2);

double b = Math.pow((p1.getY()-p2.getY()),2);

dist=Math.sqrt(a+b);

System.out.println(dist);

}

public static void main(String[] args) {

Point p1 = new Point();

Point p2 = new Point();

Scanner a = new Scanner(System.in);

System.out.print(“Please input x for point 1:”);

p1.setX(a.nextDouble());

System.out.print(“Please input y for point 1:”);

p1.setY(a.nextDouble());

System.out.print(“Please input x for point 2:”);

p2.setX(a.nextDouble());

System.out.print(“Please input y for point 2:”);

p2.setY(a.nextDouble());

PointDemo s =new PointDemo();

s.distance(p1,p2);

}

}

Small series also organized a lot of Java interview materials. If you need a small partner can be private letter “interview” to xiaobian can get oh

= = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = =