20,182,332 2019-2020-1 "data structures and object-oriented programming," the first four weeks learning summary

20,182,332 2019-2020-1 "data structures and object-oriented programming," the first four weeks learning summary

Learning content summary

  • The difference between classes and objects:

    • Different definitions:

      class is the real world or thought world entities reflected in the computer, it will operate on the data package and the data together.

      The object is a variable of class type. Classes and objects in object-oriented programming concepts most basic.

    • Different categories:

      class is an abstract concept, it does not exist in reality time, space, knowledge class for all objects define abstract properties and behavior.

      Object is a concrete class. It is the existence of a real thing.

    • Different states:

      class is a static concept, the class itself does not carry any data. When not creating any data for the class, the class itself does not exist in the memory space.

      Object is a dynamic concept, each object there are unique properties and behavior of their own distinct from other objects, attributes can change their behavior as it occurs.

  • The relationship between classes and objects:

    • Class is an abstract object, and the object is a specific instance of a class.
      Class is abstract, do not take up memory, and the object is a specific, up storage space.
      Class is a blueprint for creating an object, it is a software template definition includes methods and variables in specific types of objects in.

    • Relationship with the object's class as the object instantiated result relationship class and the casting mold, and the abstract class is a class of object, class describes a group of objects with the same properties and the same method.

  • How to understand this?

    • this represents the object reference

    • this .name property transfer

    • this.func () modulation method

    • this. (string name, int age) in a constructor can call another constructor must be written in the first line.

  • Object-oriented three characteristics;
    • Package: the objective things packaged as abstract classes, class methods and data inside the internal open method of external hidden and provide access.

    • Inheritance: Inheritance is one that can use an existing class all the features and without changing these features extend the case of the original class.

    • Polymorphism: polymorphism refers to the so-called method of the same instance of a class, there are different forms in different situations.
  • Object attributes:

    • Various features of the object attribute of the object is provided, each attribute of each object with a specific value.
      • Example: Height = 180cm.
  • Methods object:

    • The method of operation of the object is on the object, that the object can do.
      • Example: Cai Xu Kun approach: sing, dance, rap, basketball.

        Code debugging and problem solving in the process

Code hosting

【image】

Last week exam wrong question summary

1、Consider a sequence of method invocations as follows: main calls m1, m1 calls m2, m2 calls m3 and then m2 calls m4, m3 calls m5. If m4 has just terminated, what method will resume execution?
A .m1

B .m2

C .m3

D .m5

E .main

  • Analysis: Once the method terminates, control will continue to use the method calls the method. In this case, m2 calling m4, so that when m4 is terminated, m2 is restored. (Plain English did not fully understand the meaning ...)

2、A variable whose scope is restricted to the method where it was declared is known as a(n)

A .parameter

B .global variable

C .local variable

D .public instance data

E .private instance data

  • Analysis: Local variables are those declared "local" variables, that is, they can only be accessed in the process. Global variables are those that can be accessed from anywhere, while variable parameters are passed to the method. Examples of the data can be viewed as a global variable of the entire object.

3、A class' constructor usually defines

A .how an object is initialized

B .how an object is interfaced

C .the number of instance data in the class

D .the number of methods in the class

E .if the instance data are accessible outside of the object directly

  • Analysis: Constructor (constructor) is a special method. Mainly used to initialize the object when you create an object, an object that is assigned an initial value of the member variables, always use the statement to create objects with the new operator.

4、 Having multiple class methods of the same name where each method has a different number of or type of parameters is known as

A .encapsulation

B .information hiding

C .tokenizing

D .importing

E .method overloading

  • Analysis: When the process of sharing the same name, which is referred to as reload. Number and type of arguments passed in the message provide information to invoke the appropriate method.

5、Instance data for a Java class

A .are limited to primitive types (e.g., int, float, char)

B .are limited to Strings

C .are limited to objects(e.g., Strings, classes defined by other programmers)

D .may be primitive types or objects, but objects must be defined to be private

E .may be primitive types or objects

  • Analysis: Examples of data entities is an integral type, may be any available type (either a primitive type or object type), the type may be a public or private type. By way of example using the object data, which allows the construction of classes on the basis of other classes. If a class has another class instance data, this relationship is referred to as a has-a relationship.

6、An example of passing message to a String where the message has a String parameter would occur in which of the following messages?

A .length

B .substring

C .equals

D .toUpperCase

E .none of the above, it is not possible to pass a String as a parameter in a message to a String

  • Analysis: toUpperCase message length and no parameters, int substring two parameters. For equals, the string must be passed as a parameter to the message received character string with a string parameter may be compared as.
    . 7, Definition of The header following Method A syntax error in Will Result: public void aMethod ();

    A .true

    B to false.
  • Analysis: syntax error reason is that it ";" the end of the symbol. Instead, it requires zero or more in brackets {} followed by the instruction. Abstract method will be ";" end, but the head does not define abstract methods.

    Reflection:

    Experiment and downright week, Effort.

    Pair peer review and

    Reference material

  • "Java programming and data structures Course (Second Edition)"

  • "Java programming and data structures Course (Second Edition)" Study Guide




    ㅤ | number of lines of code (add / accumulate) | blog quantity (Add / accumulate) | learning time (add / accumulate) | important growth
    - - | --- | --- | --- | ---
    target | 10000 lines | 30 Pian | 400 Xiaoshi | ㅤ
    first week | 138/138 | 2/2 | 23/23 | reduced by using a mouse the number of times
    the second week | 749/887 | 1/4 | 25/48 | deepening feelings for JAVA
    third week | 765/1652 | 1/4 | 25/48 | JAVA feelings to deepen
    the fourth week | | | |

Guess you like

Origin www.cnblogs.com/Stark-GR/p/11613302.html