Interview Angle Interpretation Java engineer (i) (i.)

Source: Internet
Author: User
Tags serialization

Source: locality,

http://www.jianshu.com/p/a0b8b6f17888

Objective:

I believe that every programmer is trying to live. A lot of people because of interest, since then embarked on the "big brain action" of the golden bridge, there are many people because of dreams and perseverance, desperate to integrate into this profession, there are many people because the reality is forced too helpless, have to for themselves, for their families, for the future to seek such a bumpy road.

here, I do not judge what, and I also do not have the qualifications to evaluate Ah. To get down to the bottom, I write this article is the location of the audience, if you think I will say the next content is similar to the book, then please raise your feet to move it, but I believe you will not feel like This. Do not know that as a programmer, you are still holding an interview or a pen test review it? Are you still holding a variety of interview books to mess up?

I only say that the purpose of the interview is not to let the examiner know how you are, but to let yourself know how you are. That means what you do and what you can do! For example, If you go to an interview with a Java engineer, you will have at least the function of the job, rather than just interviewing and doing a pen Test. so, This is what I wrote this article originally!

first, the basic article

1. Three main features of object-oriented

inheritance, encapsulation, Polymorphism

What is inheritance?

① inheritance is one of the important reasons that object-oriented programming can improve the efficiency of software Development.

② inheritance is transitive, just as the grandson of reality not only looks like his father but also his grandfather.

The properties and methods inherited by ③ are implicit, which is invisible in this class.

④ A class can have only one parent class, that is, a class can only be single-inheritance.

⑤ an interface can have more than one parent class, that is, an interface can be multiple inheritance.

In the actual project development, one class inherits from another class, then the former is the subclass of the latter, and Vice Versa.

What is encapsulation?

The object data and the instructions that manipulate the object are part of the object itself, enabling you to hide the data as externally as Possible.

In actual project development, the use of the most encapsulated entity classes, often with JavaBean (the class must be concrete and public, and with parameterless Constructors) Together.

So what do the entity classes have?

A: Private member variables, parameterless constructors, parameterized constructors, setter and getters methods, overriding the ToString method, overriding hashcode, and the Equals method.

What is polymorphic?

① polymorphism is that objects have many forms: reference polymorphism and method Polymorphism.

② reference polymorphism: a reference to a parent class can point to an object of this class, a reference to a parent class that can point to a child class.

③ method Polymorphism: When creating this class object, the method called is the method of this class; when you create a subclass object, the method that is called is the method that the subclass overrides or the inherited Method.

④ there are conditions for polymorphism: inheritance, rewriting.

The role of ⑤ polymorphism is to eliminate the coupling relationship between Types.

In the actual project development, Class A inherits class b, if the class B method is not rewritten in class a, the output is still the information in the Class B method (b b=new a ()), and if the class B method is overridden in class a, the output is the information in the Class A method (b b=new a ()).

2.Java Collection Frame Tree

Collection Interface: It is a root interface of the Java collection framework and the parent interface of the list, set, and queue Interfaces. It also defines the methods that can be used to manipulate list, set, and Queue-additions and Deletions.

Map Interface: It provides a mapping relationship where elements are stored as Key-value pairs (key-value). The map interface has an important implementation class HASHMAP.

① the Key-value pair in the map interface exists as an object instance of the entry Type.

② in the map interface, the key value (key Value) is not repeatable, the value can be repeated, that is, there is a many-to-one relationship.

③ provides a collection of key values, a collection of value values, and methods for entry collections, respectively, in the map interface.

The ④MAP supports generics, and both the key and value values can be Null.

⑤ the Entry object in HashMap is unordered, and this attribute is the opposite of the list interface.

⑥ has a mapping that has only one key value of NULL in HASHMAP. (note: The key value cannot be duplicated.)

List interface: The list interface has an important implementation class ArrayList (array sequence).

①list is a set of elements that are ordered and can be duplicated.

②list can precisely control where each element is inserted, or delete the position of an element.

Comparator interface: a temporary comparison rule. If a class is to implement this interface, it is necessary to implement its compare () Method.

Comparable interface: the default comparison Rule. When this interface is implemented, it means that instances of this class can be compared in size and can be naturally sorted. If a class is to implement this interface, it is necessary to implement its CompareTo () method.

Io stream in 3.Java

BYTE stream:

Read and write one byte at a byte

FileInputStream in=new FileInputStream ("source file");

FileOutputStream out=new FileOutputStream ("target file");

......

In.close ();

Out.close ();

The first thing to remember is that once the IO stream is used, it is common sense to always remember to close it.

Efficient reading of bytes using buffers

Bufferedinputstream in=new bufferedinputstream (new fileinputstream ("source file");

Bufferedoutputstream out=new bufferedoutputstream (new fileoutputstream ("target document");

......

In.close ();

Out.close ();

Character Stream:

InputStreamReader isr=new inputstreamreader (new fileinputstream ("source file path"), "set encoding");

OutputStreamWriter osw=new outputstreamwriter (new fileoutputstream ("destination file path"), "set encoding");

......

Osw.close ();

Isr.close ();

You can also write this:

FileReader fr=new filereader ("source file path");

FileWriter fw=new FileWriter ("destination file path");

......

Fr.close ();

Fw.close ();

Efficient reading of characters using buffers

BufferedReader br=new bufferedreader (new filereade ("source file path");

PrintWriter pw=new printwriter ("destination file path");

......

Br.close ();

Pw.close ();

Serialization and Deserialization:

Serialization of objects

ObjectOutputStream oos=new objectoutputstream (new fileoutputstream (file));

The file here refers to the string file= "the path of the files in the project";

Deserialization of an object

ObjectInputStream ois=new objectinputstream (new fileinputstream (file));

4.Java Socket Communication (multi-threaded)

Ideas:

① first creates a server-side socket, specifies and listens for a port, and then loops through the connection to start waiting for the client ....

② Creates a client socket, specifies the server address and port, then gets the output stream, sends the request to the server side, and closes the socket output Stream.

After the Client's request is received by the ③ server, a new thread is created and Started.

④ creates a threading class, performs a thread operation, gets the input stream, and the server reads the client user details to close the Resource.

⑤ executes the thread operation, gets the output stream, responds to the client request, and the client receives a response to the server, shutting down the Resource.

Simply put, it's the equivalent of me talking to you (client → Server side), You receive what I say (server → threading class), brain after thinking (threading class), make an answer to my words (threading class → client).

5. Relational Database

The three paradigms of the database:

The ① field is not Divided.

The ② has a primary key, and the Non-primary key field relies on the primary key.

③ non-primary key fields cannot depend on each other.

T-sql:

In the entire database, query operations occupy 80% of the added and deleted changes, and when it comes to queries, t-sql statements naturally not less. Shown Above.

Increase:

① inserting a single line

INSERT into < table name > (column name) values (column values)

② Adding existing table data to a table that already exists

INSERT into < existing new table > (column Name) Select < source table column name > from < source table name >

③ Create a new table directly with the existing table data and populate

Select < new table column name > into < new table name > from < source table name >

By deleting:

① Delete a row that satisfies a condition

Delete from < table name > where < delete condition >

② Delete an entire table

TRUNCATE TABLE < name >

Note: Delete all rows of the table, but the structure, columns, constraints, indexes, etc. of the table are not deleted;

Change:

① Update

Update < table name > set < column name = update value > where < update condition >

Sub-query:

SELECT * from t1 WHERE column1 = (select column1 from t2);

which

①select * from T1 ... Called an out-of-query.

②select Column1 from T2 is called a subquery.

so, Let's just say that subqueries are nested inside of Queries. In fact, it is also possible to nest one or more sub-queries inside a subquery. Note here that the subquery must appear between the parentheses Oh.

Interview Angle Interpretation Java engineer (i) (i.)

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.