This article for the author in the learning process according to teacher's guidance to organize themselves.
1. JDK, JRE, JVM
①jdk:java Development Kit Java Development Kit
②jre:java Runtime Environment Java Runtime Environment
③jvm:java Virtual Machine Java VM
2, briefly describe the process of compiling and running Java program
The ①java compiler translates the Java source program into a JVM executable code-bytecode, and after the source file is created, the program is compiled into a ". Class" file.
② when the compiled Java program gets the ". Class" File and runs the. class file using command Java, the system starts a JVM process and finds the portal of the main function and starts executing the main function.
3, eight basic data types and byte size
①byte 8-bit
②short 16-bit
③int 32-bit
④long 64-bit
⑤float 32-bit
⑥double 64-bit
⑦boolean 1-bit
⑧char 16-bit 4, use nested for loop to print the 99 multiplication table.
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 delivery and reference delivery
① value Transfer: Value transfer is the transfer of the value of the copy, and then the copy of the value after the transfer, the transfer process does not change the size of the original value;
② Reference passing: A reference pass is an address that needs to pass a value, and the delivery process changes the size of the original value.
2, what is the method overload
Method overloading is a method that defines multiple methods with the same name in a class, but requires each method to have the number of types or parameters of different parameters.
3, 4 different description of access control characters
①private (current access): A member declared Private can only be accessed by other members of the current class, not outside the class;
② Default (Package access): If a member of a class or class has no access control before it, the default access is obtained, and the default can be accessed by all classes in the same package;
③protected (Subclass Access): A member declared as Protected can be accessed by other classes in the same package, or by subclasses in different packages;
④public (Public access rights): a member declared as publicly can be accessed by all classes in the same package or in different packages, that is, public access modifiers can make the attributes of a class common to any class.
4, write out 8 basic data types to provide the corresponding packaging class
①byte byte
②short Short-integer
③int Integer Integral type
④long Long Integral type
⑤char Character Character type
⑥float float single-precision floating-point
⑦double double double double-precision floating-point type
⑧boolean Boolean Boolean type
5, what is the box and unboxing
① Boxing: Refers to the conversion of the basic type data value to the corresponding package object, the data in the stack is encapsulated into an object to be stored in the stack;
② unboxing: Unboxing is a boxed reverse process, which is the process by which the encapsulated objects are converted into basic types of data values, and the data values in the heap are stored in the stack.
6, the difference between String and StringBuilder
①string the string built by the innovative string is immutable, if you change the value of a string variable, you create a new string in memory, and the string variable references the newly created string address, while the original string remains in memory and the contents remain unchanged until the Java garbage collection system destroys it;
②stringbuilde creates a mutable string that StringBuilder not thread-safe and therefore performs better.
Write a Pointdemo class, and provide a distance (point P1,point P2) method to calculate the distance between two points, instantiate two specific node objects and show 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 to 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 to point 2:");
P2.sety (A.nextdouble ());
Pointdemo s =new Pointdemo ();
S.distance (P1,P2);
}
}