20172319 2018.03.27-04.05 "Java Programming" 4th Week study Summary

Source: Internet
Author: User

20172319 2018.03.27-04.05 "Java Program Design" 4th Week study summary textbook Learning content Summary fourth Chapter writing class
    1. Review of classes and objects: The object is stateful, and the state is determined by the property value of the object. Properties are defined by the variables declared in the class. The operation of the object may change the state of the object. The operation of the object is defined by the method declared in the class.
    2. Class Analysis: The members of the class (data and methods of the Class), the construction method (assigning the initial value to the class), the instance data (where the variable declaration is defined), and the UML class diagram (the class and its object relationship visual description).
    3. Encapsulation: (1) Visibility modifier: public, private (privately, only accessible from inside), protected (only related to inheritance).
      ?? ??????? (2) Accessor: GetX, modifier: SetX.
    4. Method Analysis: Call method, return statement (Get return value), argument, parameter (method declaration header parameter name); Local data (declared and used in method).
    5. Review of the construction method: Same as the class name; no return value; often used to initialize instance objects.
The seventh chapter object-oriented design
    1. Software development activities: four basic processes for development activities: Determining software Requirements-Software design-implementing software design-software testing.
    2. Explicit classes and objects: Class identification (Naming the class, distinguishing the domain of the problem), and the function of the class (declaring the method to define the behavior of an object).
    3. Static class Members: Static variables/class variables (static, shared by all class instances), static methods (called by classes), and main methods (only static or local variables can be accessed).
    4. Inter-class relationships (most basic: dependencies, aggregations, and inheritance): dependency (A must invoke a method by accessing an instance of B, the object of the class can be passed as a parameter to the method of this class);
      ?? ? Aggregation (Object collection into object, containment relationship); This reference (the object that is currently running; and the constructor and instance variables that have the same name).
    5. Interfaces (public methods that interact with objects): a set of constants and abstract methods, which cannot be instantiated, can be implemented by multiple classes of the same interface, and a class can implement multiple interfaces;
      ?? ? Comparable interface (compare to method); Iterator interface (the operation moves to the next object at one time).
    6. Enumeration type (special Class): In fact, an enumeration value, whose value is an object; contains static methods values (a list of all enumerated values (an iterator that can be used to process its values for a loop statement)).
    7. Method Design: Method Decomposition (one method is decomposed into multiple methods), method parameters are passed by value, and called by reference.
    8. Method overloading: Calls multiple methods using the same method name.
    9. Test: Review, defect test (black box test and white box test).
Problems in teaching materials learning and the solving process
    • Is the question 1:private not privatization? Why are you using public again in the back?
    • Workaround: Private is a property that increases its security by privatizing it, allowing users to access data only through the methods public provides.

    • Question 2: The book says that the die reference variable points to the address of the respective Die object (what?). )
    • Resolution: That is, the output is followed by the strange character behind the variable, under normal circumstances, hidden, but what if the missing statement (at that time, the die operation of a wave, the truncated figure is missing), it will be displayed in?? ? After the variable.

    • Issue 3: Construction method ... Is it really useful?
    • Solution: nonsense, useless . When assigning values to a property, it is easy to forget to assign a value to one or more of them. Construction methods can simplify object initialization and assign values to instance variables.

    • Issue 4: Construction method with Parameters ... What is this?
    • Workaround: The instance variable can be displayed to be given an initial value. Create different objects under different conditions, and the instance variables of those objects have different values. is something in the back () of new.

    • 5: The implementation class can only be used with those specific methods in the interface?
    • Workaround: Implementing an interface class must define the methods that are contained in the interface, but allow other methods to be defined in the interface.

      Problems in code debugging and the resolution process
    • Question 1: Why can't javac the things that are knocked out of the textbook?
    • Resolution: (1) First Javac class, then javac its test file, and then move to the Bin folder.
      ?? ?? (2)javac -d bin/ src/*java

    • Question 2: The class has been compiled, but the operation is problematic.
    • Solution: There are some characters in the class error, machine check out, can only be used to troubleshoot.


    • Question 3: When practicing pp4.5, I want to output the statement in the class, but find out how to change the data Boolean is false.
    • Solution: At first, the Isantique method in the class was referenced in the test, followed by the increase of the training system, knowing that the original method was not referenced to the class itself in the output.



Code Hosting

Last week's summary of the wrong quiz
    • Wrong Title 1:

    • Understanding: A string is immutable, and once a string object is created, it cannot be changed. The shortest string is "" with no characters between the quotation marks, so the length is zero.
    • Wrong Title 2:
    • Understanding: The compiler is able to detect an attempt to use an uninitialized variable, in which case it produces a syntax error. If escape detection, such as using the compiler, a run-time error occurs when it is used.
    • Wrong Title 3:
    • Understanding: A pseudo-random number is generated within the [0,1] range, multiplied by 10 to get the number in the range [0,10], minus 5 to get the number in the range [ -5,5].
    • Wrong Title 4:
    • Understand: Both statements are legitimate java. S1 is a string reference that is initialized to string "testing123". S2 is a string reference,
      ?? ? It is initialized to the string "Testing 123". Notice the distance between "test" and "123". So the two strings are not equal.
    • Wrong title 5:
    • Understanding: NumberFormat always loops; It never truncates. Moreover, it provides a method of currency and percentage.
    • Wrong title 6:
    • Understanding: Import statements can only be used with one (wildcard). If you also need to import all the secondary levels of a package, you must explicitly write them out:
      ?? ? Import Package. A.
      ;
      ?? ? Import package. b.*;

      Other (sentiment, thinking, etc., optional)




Learning progress Bar
lines of code (new/cumulative) Blog Volume (Add/accumulate) Learning Time (new/cumulative) Important Growth
Goal 5000 rows 30 Articles 400 hours
First week 202/202 1/2 15/15 Active Tapping Code
Second week 490/692 1/3 18/33 Be good at thinking
Third week 581/1273 1/4 15/48 Good at improving
Week Four 1857/3130 1/6 33/81 Tired

20172319 2018.03.27-04.05 "Java Programming" 4th Week study Summary

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.