20165219 2017-2018-2 "Java Programming" Week 9 Learning Summary

20165219 2017-2018-2 "Java Programming" Week 9 Learning Summary

Textbook Knowledge Summary

URL class

  • The URL class is an important class in the java.net package. Applications that use URLs to create objects are called client programs. A URL object usually contains the most basic three parts of information: protocol, address and resource.

  • Construction method:public URL(String protocol,String host,String file) throws MalformedURLException InetAddress

public URL (String spec) throws MalformedURLException

InetAddress class

UDP datagram, broadcast datagram

socket

  • The combination of source IP address and destination IP address and source port number and destination port number is called a socket

  • The server establishes a ServerSocket object, the ServerSocket object is responsible for waiting for the client request to establish a socket connection, and the client establishes a Socket object to send a socket connection request to the server.

Java remote call

Summary of wrong questions

1 Which of the following statements is correct?

A. The JVM considers this application to have a total of two threads.

B . JVM认为这个应用程序只有一个主线程 。

C. The JVM considers this application to have only one thread.

D. The program has compilation errors and cannot be run.

2 Which of the following statements about daemon threads is correct?

A . thread.setDaemon(true)必须在thread.start()之前设置,否则会报IllegalThreadStateException异常。

B . 如果用户线程已经全部退出运行,只剩下守护线程存在,那么虚拟机也就退出了。

C . 将线程转换为守护线程可以通过调用Thread对象的setDaemon(true)方法来实现。

D . 守护线程应该永远不去访问固有资源,如文件、数据库,因为它会在任何时候甚至在一个操作的中间发生中断。

code hosting

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324978484&siteId=291194637