Summary and summarization on the problem of the Java face of the cow net (1) __java

Source: Internet
Author: User
Tags garbage collection thread class
Preface

Today, in the Nuggets, I saw an article about the spring framework for the presentation, which referred to the face test of the cow net. So I downloaded the Cattle Network app, found the interview topic is very rich. I chose the Java aspect of the face test to do a bit. 10 topics for a group of interview questions, finished, I found myself a lot of wrong, most of them are basic questions. As the saying goes: The depth of the foundation determines the height of the future. I feel that I have to do a mistake to sum up and summarize, the previous learning Java process missing points of knowledge to review again, just take this opportunity. At the same time, I also think that theoretical knowledge is very important, the theory of thinking, supporting the quality of the code. Summary of the wrong question

Question 1th.

Induction: 1. The method name must be the same as the class name 2. Do not declare return type 3. The construction method can be modified by final,private 4. There is at least one construction method 5 in a class. Java default call parameterless constructor when class does not provide a constructor method with a parameter

Question 2nd.

Summary : 1. The Super keyword 2 is used whenever a subclass calls a method that inherits from the parent class in a method that overrides the override parent class. A subclass calls a method that inherits from the parent class and is called directly without using the Super keyword.

Question 3rd.

This topic is very easy to make mistakes, think very simple certainly is 4. In fact, the correct answer is 10, because the lack of break, can not jump out.
Induction: When there is no break in the switch structure, matching to the appropriate value, will not jump out. It will always match to the last case until the entire structure is finished.

Question 4th.

Induction: First the string calls the substring () method to obtain a substring from the current string, which is the string that is intercepted from the start of the current string to the end, but does not contain the corresponding character of the last quarter. garbage collection is primarily for the collection of heap-area memory, because the stack area's memory is freed with threads. The heap area is divided into 3 districts: The young generation, the old generation, and the permanent generation (method area).
Young generation: objects created by the new operator are usually assigned to the younger generation. The Minor GC (Minor GC is the garbage collector for the young generation of memory) also survives the object being moved to the older generation. older generation: It's from the younger generation and some of the larger objects. The full GC is a garbage collector for older generations. permanent Generation: stores the final-decorated constants, static variables, and constant pools.

Answer:
First STR0,STR1 is a static constant, stored in a permanent generation of heap memory. STR2 is also a new object, because substring's source code is actually new a string object and returns, STR3 and STR4 are created directly by the newly operator. STR2,STR3,STR4 is a young generation stored in the heap area. After the full GC, the memory of the older generation is scavenged and reclaimed. If it is not a permanent generation, only young generations remain. So young generation 5*3=15 a number 5th question

Induction:
The difference between the default package and the protected: The former is denied access as long as it is an external package. The latter can be accessed as long as it is a subclass, and the instant subclass is in the outer package. Question 6th.

Induction:
Wait () and notify () are the methods of the object, while sleep is the method of the thread class. Wait () and sleep () throw interruptedexception and must be caught by exception. The call to wait () and notify () must be invoked with the current lock, that is, the object in synchronized must be taken.

Question 7th.

Answer:
Dst=new String (src, "GBK"). GetBytes ("UTF-8");
Induction: First, by a new string (SRC, "GBK") to revert to a string object, the call string Object GetBytes ("UTF-8") to get UTF-8 encoded byte array

Question 8th.

Induction: Genericservlet is an abstract class that must be given a subclass to instantiate. It gives some skeletons in the design servlet, defines the servlet lifecycle, and some methods for naming, configuring, and initializing parameters. HttpServlet is a subclass of Genericservlet, and also adds doget,doPost,dodetele,dotrace Methods to handle the request-response process for commands in the HTTP protocol. Most servlet implementations are extended through Genericservlet or HttpServlet classes. The ServletConfig interface defines an object that is passed to the servlet for configuration information by the servlet container during servlet initialization. The HttpServletRequest interface extends the ServletRequest interface to provide HTTP request information for HttpServlet. Question 9th.

Induction:
Programmers are not allowed to overload operators in Java. If "+" is a string, it is considered a connection string. If "+" is a string before "+" is the base data type, then it is considered a connection. If "+" is the base data type, then the addition operation is considered. If "+" is followed by a reference to a type variable, then the object's ToString () method 10th is called

Induction:
Streaming media is a technology that enables audio, video, and other multimedia information to be played on the Internet and on the intranet (enterprise intranet) without downloading waiting. Tail words

The

insists on keeping some of the basics of missing knowledge fresh every day.

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.