201671010111 2016-2017-2 << Java Programming >> Learning Summary

Source: Internet
Author: User

The teacher's reversal class is one side to study the new knowledge point in the back while reviewing the previous old knowledge mode, because the knowledge of the first three chapters of Java is a review of the C language, so the teacher tested directly last week. But today the teacher did not direct examination but first to explain the third chapter left some problems, and then take us through the title to grasp the fourth chapter of knowledge points.

The third chapter of the test question has such a topic:

If you have the following program code:( string , array)

String[] STRs = {"Java", "Java", "Java", "Java", "Java"};

The following statement is correct.

A, produces 5 string instance B, produces 1 string instances

C, generate 0 Instances of string D, compile failed

At that time in the classroom we choose a A, a two answer, then the correct answer to this question is a. is because the Java virtual machine is a direct amount of strings that have the same string sequence for increased efficiency and memory savings.

There are many differences between the input and output C language and Java: C language input with scanf, output with printf. Java input with scanner, output System.out.

Chapter Fourth Class and Object

The class body contains the instance domain and the method two parts, this method is the same nature as the function in C language. The In-class methods have access to the instance domain, so that secure access to the data is achieved through encapsulation. An object contains three parts: The behavior of an object, the state of an object, the identity of an object, and each object has a unique identity. The construction of objects requires Java to provide a variety of mechanisms for writing constructors. A constructor is a special method that is called when an instance of a class is generated, and is often called by the new operator.

When you need to get or set the value of an instance field, you should provide the following three things:

a private data field;

A public domain accessor method;

A public domain-change method.

The benefit is that the internal implementation can be changed, except for the method of the class, which does not affect other code. You can also perform error checking, and then assign values directly to the domain.

201671010111 2016-2017-2 << Java Programming >> Learning 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.