As the first Dark Horse technical blog It is necessary to explain the background. The personal understanding of the blog is to be used in communication, in his study, in the exchange of learning to grow together. Let's get down to the chase. This article is mainly to introduce the black horse in the introduction of testing some of the problems (this should not leak the question bank).
First analysis of 10 sets of questions, mostly is the basic knowledge, I believe that participated in the software competition colleagues and learned Bi Xiangdong Teacher Java Foundation of the colleagues smoothly through this is not too much problem.
The first question is about the basic algorithm knowledge, this is necessary to master the following, in the school also often listen to the teachers said to find a job interview will be some of this knowledge, I got the first question is about the sort, although very simple, but I still want to remind the Foundation is not very good students to learn. Algorithm is the core of programming, but also the soul, its importance does not need me to say more, I need to hint is to insist on learning algorithm, because the algorithm is the internal strength (pull a bit more).
The second question is about the Fibonacci sequence, which is also very basic, mainly to examine your ability to analyze data and to understand recursion. Believe that the middle school can be determined to meet the various Z knowledge of the series, the data between the law also has a certain insight, so I do not think this problem will be everyone's problem (mathematics is the fundamental of the algorithm AH).
The third question is some basic knowledge about type conversion, and the students who understand the type conversion can skip it, but I think it is necessary to remind. I think the dark Horse teacher's starting point is very good, is to examine the student to the basic Knowledge mastery degree. Insert the original question below, I hope it will not involve the issue of leakage.
Analysis: Which of the following code is correct? Why?
A. Byte B = 1 + 1;
b. Byte B = 1; b = B + 1;
c. Byte B = 1; b = b + = 1;
D. Byte B = 1; b = ++b;
A. I believe everyone has no problem (of course, if you do not understand the type of conversion is problematic, although no compile and run no problem, but the following questions will appear overwhelmed).
B. I believe in everyone and find out the problem, the compilation is through. Because you are trying to assign a variable of type int to a byte variable. This results in a loss of precision, so compilation fails (compilation failure is a good thing for programmers). To tell the reason, the compiler automatically detects the byte type and the int type when the b+1 operation is done, and then it automatically transitions upward, that is, the result after b+1 is no longer a byte type, and the variable B is a byte type, and you attempt to assign the int type to byte, and the compiler fails. If you want to compile, you can force the int variable to be converted to a byte type, which will lose precision. As follows:
byte B = 1;
b = (byte) (b + 1);
C. You will find that the compilation runs without problems, but it is important that you understand why you can compile and run. The statement can be decomposed into statements first:
byte B = 1;
b + = 1;
b =b;
It is observed that the second statement is similar to the one in question B, but B compiles unsuccessfully and C passes. The reason is that the variable type on the left side of the operator is converted to the right variable type before the + = operation, and the right b+1 in question B also shows that the result of the b+1 is the int value, so the type of B in C is automatically converted to the int type. So compiling is no problem.
D. According to the analysis of C we can decompose the statement into:
byte B = 1;
++b;
B=b;
And the second sentence can be converted to b+=1. By analyzing C, you will understand the principle of D.
Summarize:
1, through the above simple analysis you should draw conclusions
A: When the basic data type is arithmetic, the result of the operation is automatically promoted with the higher level data type;
b:++, + = First, the data type to the right of the operator is coerced into the same type as the left side of the operator, and the final result is consistent with the left side of the operator
2, should have the program analysis of the law (or the Law of the Debugging program), the problem decomposition, find its equivalent of the formula; the part to be debugged is isolated from the rest, and it is to reduce interference from other factors.
3, cultivate the habit of the principle of deep-dive, which will prompt you to grow quickly.
The fourth question is about the use of iterator, which belongs to the collection framework part of the knowledge, the topic is to examine the iteration, belong to the simple level. I think the teacher wants to remind you to review the set frame.
The fifth question is about printing images, but it is a simple one, printing 99 multiplication table, this has nothing to say, for mastering the basic coding ability you certainly is not a problem.
Finally hit the ad by the rules.
-------Android Training, Java training , look forward to communicating with you! ---------
Dark Horse Programmer _ about Dark Horse Java class Entrance test technology sharing < Top 5 questions > (i)