Summary and generalization of the problem of the Java plane question in the cattle net (1)

Source: Internet
Author: User

Objective

Today, in the Nuggets, I saw an article about the spring framework of the explanation, and the article mentioned the question of the cow-guest net. So I downloaded the Ox-Guest web app and found the interview topic is very rich. I chose the Java side of the face of the question to do a bit. 10 topics for a group of interview questions, after the completion, I found myself wrong a lot, most of them are basic problems. As the saying goes: The depth of the foundation determines the height of the future. I feel I have to do a wrong to sum up and summarize, the previous study of the omission of knowledge in the Java process to review again, just to take this opportunity. At the same time, I also feel that theoretical knowledge is also very important, theory around the idea, supporting the quality of the code.

Wrong problem induction
    • Question 1th

      Write a picture description here

      Induction:
      • 1. The method name must be the same as the class name
      • 2. Do not declare return types
      • 3. The construction method can be modified by final,private
      • 4. At least one of the constructor methods in a class
      • 5. When the class does not provide a constructor method for the argument, Java defaults to calling the parameterless constructor
    • Question 2nd

      Write a picture description here

      Induction

      :

      • 1. Use the Super keyword only when overriding a method in the override parent class when the subclass calls a method that inherits from the parent class
      • 2. Subclasses call methods that inherit from the parent class, and do not need to use the Super keyword to call directly.
    • Question 3rd

      Write a picture description here

      It's easy to make a mistake without looking at the subject, which is certainly 4. In fact, the correct answer is 10, because the lack of break;

      Induction:
      1. 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 end of the entire structure.
    • Question 4th

      Write a picture description here

      Induction:

      1. The first string calls the substring () method to obtain a substring from the current string, which is a string that is truncated from the start of the current string to the end, but does not contain the corresponding character of the end.
      2. Garbage collection is primarily about the recycling of heap memory, because the memory of the stack is released as the thread. 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 young generations. A certain Minor GC (Minor GC is a garbage collector for younger generations of memory) also survives objects that are moved to older generations.
        • older generation: It is the young generation that moved over and some of the larger objects. The full GC is for the old generation garbage collector.
        • permanent Generation: stores the final modified constants, static variables, and constant pools.

      Answer:

      First STR0,STR1 is a static constant, stored in the heap memory for a permanent generation. STR2 is also a new object, because substring is actually a new string object in the source code, and returns, STR3 and STR4 are created directly from the newly operator. STR2,STR3,STR4 is a young generation that is stored in the heap area. After the full GC, the old generation of memory is cleaned up and recycled. No permanent generation, only the younger generation. So the younger generation 5*3=15 the number of characters

    • Question 5th

      Write a picture description here

      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 the subclass is in the outer package.
    • Question 6th

      Write a picture description here

      Induction:
      1. Wait () and notify () are methods of the object, and sleep is the method of the thread class.
      2. Wait () and sleep () all throw interruptedexception and must be caught for exception.
      3. Calls to wait () and notify () must be called with the current lock, that is, the object in synchronized must be used.
    • Question 7th

      Write a picture description here

      Answer:

      Answer:

      Dst=new String (src, "GBK"). GetBytes ("UTF-8");

      Induction:
      • The GetBytes ("UTF-8") of the string object is converted to a string object by first using the new string (SRC, "GBK") to get a UTF-8 encoded byte array
    • Question 8th

      Write a picture description here

      Induction:
      1. Genericservlet is an abstract class that must be given a subclass to instantiate. It gives the skeleton of the design servlet, defines the servlet life cycle, and some methods of getting the name, configuration, and initialization parameters.
      2. HttpServlet is a subclass of Genericservlet, also added doget , doPost , dodetele , dotrace and other methods to handle the request response process for commands in the HTTP protocol.
      3. Most servlets are implemented through Genericservlet or HttpServlet classes.
      4. The ServletConfig interface defines the objects that are passed by the servlet container to the servlet for configuration information during the servlet initialization process.
      5. The HttpServletRequest interface extends the ServletRequest interface and provides HTTP request information for HttpServlet.
    • Question 9th

      Write a picture description here

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

      Write a picture description here

      Induction:
      • Streaming is a technology that enables audio, video, and other multimedia information to be played on the Internet as well as in the intranet (intra-enterprise network) without downloading the wait.
Tail words

Adhere to the basic knowledge of the omission of the day to know the new.

Welcome to join the Learning Exchange Group 569772982, we learn to communicate together.

Summary and generalization of the problem of the Java plane question in the cattle net (1)

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.