1. Summary of this week's study
2. Written work
Code Reading
public class Test1 {
private int i = 1;//This line cannot be modified
private static int j = 2;
public static void Main (string[] args) {
Geti ();
TEST1.GETJ ();
}
public static void Geti () {
System.out.println (i);
}
public static void Getj () {
System.out.println (j);
}
}
Can the above code be compiled and passed? Where does it go wrong? Trying to correct?
If you create 3 Test1 objects, there are several I in memory, a few J? Please analyze the reason? A: Cannot compile pass, System.out.println (i) This line is wrong, because I is not defined by static type, correct: change public static void Geti () to public void Geti (i) If you create 3 Test1 objects, there will be 3 I, a J.
What is the use of constructors? What is the writing format? If a class does not write a constructor, does it have a constructor function? If a class has only a constructor with parameters, does it have a default constructor with no arguments? A: Constructors initialize a class, write a format: the constructor name is the same as the class name, and if a class does not write a constructor, the system defaults to a parameterless constructor, and if a class has only a constructor with parameters, it should have no default constructor with no arguments.
Why don't you need new when using a function of the Java.lang.Math class? What happens if new Math () generates errors? Analyze the cause? A: A compilation error is generated.
What is overloading? What is a constructor overload? In the Java.lang.Math class cited out 1 examples of function overloading? How can I distinguish between two overloaded functions? A: A function or method has the same name, but a different argument list, a function or method with different parameters of the same name, which is called an overloaded function or method. Differentiate two overloaded functions by relying on their argument list.
The final modified variable cannot be changed, why does the following code work?
Final int[] numbs= {1,2,3,4,5};
NUMBS[2] = 1; A: The final modified variable cannot be changed, it means that the value of the variable cannot be modified, and the value of the object that the variable points to can be modified.
Read the code Employeetest.java and answer:
Why are their properties private? What are the benefits of this design?
Add an parameterless constructor for the employee class, call its parameter constructor, set name to employee 1, salary to Hireday, and the date of the month is March 5, 2017. (Paste code)
Add an additional parameter constructor for the employee class, with only name and Salary,hideday as the current date. (Paste code)
Write function public static Boolean ismondaytofriday ()
Function: Judging today if it is Monday to Friday, direct output such as "work Time" and return true, otherwise output "break time".
Tip: Use LocalDateTime, DayOfWeek
Resources:
JAVA 8: Robust, easy-to-use time-date api-importnew.pdf
Java8datetimetest.java
Runnable Jar (optional)
The programs we've written before must either open Eclipse or copy the appropriate. class file to run under the command line, and if the. class file is large and has a package name in the file, you need to copy the complete directory structure and file to run. Now you want to hit the Java file in the Eclipse project into a runnable jar package that runs directly on the command line. Transform the topic 7 to receive parameters from the command line, the parameter is year-month-day, the item is hit into a jar package, and then run through Java-jar on the command line, and. The reference file is as follows:
3. Code Cloud Codes Submission record
In the Code cloud Project, select statistics-commits history-set time period, and then search for and
4. PTA Experiment
Topic set: jmu-java-03-Object-oriented 1-basic-encapsulation inheritance in programming (5-1, 5-2, 5-3)
There must be an experimental summary.
201521123106 the third week of Java Program Design Study summary