Java - SE Short answer 3

1.  oriented and object-oriented process distinction. ( 5 points)

  1. Different programming ideas: process-oriented to achieve the main function of the development of the function, to the first object-oriented abstract classes, attributes and methods, and then completion by instantiating the class, perform the method. ( 1 min)
  2. Encapsulation: encapsulation has, but the process is for the package are functional, and the object-oriented data and functions are encapsulated. ( 1 min)
  3. Object-oriented have inheritance and polymorphism, but not process-oriented inheritance and polymorphism, object-oriented advantages are so obvious. ( 1 min)
  4. Object-oriented coupling low, more conducive to modify maintenance. (Rice bowl / fried rice). ( 1 min)
  5. Process-oriented is more suitable to solve simple problems. The object is more suitable for solving complex problems. ( 1 min)

Rating Requirements: If the content is different from the above answer, but it is justified, as appropriate to the sub.

 

2. Error and Exception different. ( 5 points ) 

  1. Error class represents a serious error alone can not restore the program itself, such as memory overflow, dynamic link error, VM error. ( 1 minute) the application is not this type of object should be thrown out. If this error occurs, in addition to trying to make the program safe exit, but in other respects is powerless. ( 1 min)
  2. Exception class, the Java non-fatal errors thrown and processing applications, such as the required file is not found, divide by zero, array index out of bounds and so on. ( 1 min) its various subclasses correspond to a different type of the exception. It can be divided into two categories: the Checked Exceptions and Runtime exceptions. ( 1 minute) so during the program design should be more concerned about the Exception class. ( 1 min)

Rating Requirements: If the content is different from the above answer, but it is justified, as appropriate to the sub.

 

3. recited common byte input and output streams and describes its characteristics, at least . 5 pairs. ( 5 points)

  1. FileInputStream and FileOutputStream  nodes stream to the source and destination data file ( 1 min)
  2. BufferedInputStream and BufferedOutputStream  process flow provides a cushioning function, improve the efficiency of reading and writing ( 1 min)
  3. DataInputStream and DataOutputStream  process flow provides a convenient, read and write data types and String method of the data ( 1 min)
  4. ObjectInputStream and ObjectOutputStream  process flow not only provides a convenient, read and write data types and String method of the data, also provides a method of reading and writing data reference types ( 1 min)
  5. ByteArrayInputStream and ByteArrayOutputStream  nodes stream byte array data source and destination ( 1 min)

Rating requirements: correct input stream of bytes per team lists and describes the features and output stream of bytes 1 min, including but not limited to the above five byte stream.

 

4. What are two ways to create threads are? What advantages and disadvantages. ( 5 points) 

  1. Mode 1 : Inheritance java.lang.Thread classes, and covers the run () method. ( 1 min)

Advantage: Simple writing; ( 0.5 points)

Disadvantages: can not inherit other parent ( 0.5 points)

  1. Mode 2 : implement java.lang.Runnable interface and implement run () method. ( 1 min)

Advantages: inheritable other classes, can share the same multithreaded Thread objects; ( 1 min)

Disadvantages: slightly more complex programming mode, you need access to the current thread, to be called Thread.currentThread () method ( 1 minute)

 

5. Based DESCRIPTION UDP 's Socket main programming step ( 5 minutes) 

Server ( Server ):

1)  configuration DatagramSocket instance. ( 0.5 min)

2) create a packet of DatagramPacket , access to the transmission and reception of data, the IP and port. ( 0.5 min)

3)  by DatagramSocket example receive method for receiving client data . ( 0.5 min)

4)  by DatagramSocket the send method sent feedback information to the client. ( 0.5 min)

5) Close DatagramSocket . ( 0.5 min)

Client ( Client ):

1)  configuration DatagramSocket instance. ( 0.5 min)

2) create a packet of DatagramPacket , access to the transmission and reception of data, the IP and port. ( 0.5 min)

3)  by DatagramSocket example receive method for receiving client data . ( 0.5 min)

4)  by DatagramSocket the send method sent feedback information to the client.  ( 0.5 min)

Close DatagramSocket . ( 0.5 min)

Guess you like

Origin www.cnblogs.com/9797ch/p/11825622.html