提交 39525dca 编写于 作者: M Mars Liu

add keywords

上级 4738558b
{
"type": "code_options",
"author": "clong",
"source": "Support.md",
"exercise_id": "eac8c5c2b7b14122bdd66651e40169a5",
"notebook_enable": true
}
\ No newline at end of file
# Java基本网络支持
下列对于Java网络支持的相关说法错误的是:
## 答案
```
URI是统一资源标识符,可以用来定位资源
```
## 选项
### A
```
InetAddress类有两个子类:Inet4Address和Inet6Address
```
### B
```
URLDecoder和URLEncoder用于完成普通字符串和MIME字符串之间的相互转换
```
### C
```
URL是统一资源定位器
```
{
"node_id": "java-1e8ef0cdeec443d8addaaa79b760c6b1",
"keywords": ["network"],
"children": [
{
"使用URLDecoder和URLEncoder": {
"keywords": [],
"children": [],
"node_id": "java-f880ae75add64feaae9a85ea7c9367b2",
"title": "使用URLDecoder和URLEncoder"
}
},
{
"URL、URLConnection和URLPermission": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"title": "URL、URLConnection和URLPermission"
}
}
],
"export": ["Support.json"],
"title": "Java的基本网络支持"
}
\ No newline at end of file
{
"type": "code_options",
"author": "clong",
"source": "Proxy.md",
"exercise_id": "9ab4eaf561144775b08bf657416721af",
"notebook_enable": true
}
\ No newline at end of file
# Proxy
下列对http请求使用代理的方式正确的是:
## 答案
```
以上选择均正确
```
## 选项
### A
```java
// 在你发起Http请求之前设置代理属性
Properties prop = System.getProperties();
prop.setProperty("http.proxyHost", proxyHost);
prop.setProperty("http.proxyPort", proxyPort);
```
### B
```java
// 通过Proxy来配置代理信息
URL url = new URL("http://www.baidu.com");
Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
URLConnection conn = url.openConnection(proxy);
```
### C
```java
// httpclient设置代理
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.connectTimeout(Duration.ofSeconds(10))
.proxy(ProxySelector.of(new InetSocketAddress(proxyHost, proxyHost)))
.build();
```
{
"node_id": "java-cb9fdf69e28f40aca9ef741b9c8bc925",
"keywords": ["network", "proxy"],
"children": [
{
"直接使用Proxy创建连接": {
"keywords": [],
"children": [],
"node_id": "java-367580927af845268b72979f1e1e16be",
"title": "直接使用Proxy创建连接"
}
},
{
"使用ProxySelector自动选择代理服务器": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"title": "使用ProxySelector自动选择代理服务器"
}
}
],
"export": ["Proxy.json"],
"title": "使用代理服务器"
}
\ No newline at end of file
{
"type": "code_options",
"author": "clong",
"source": "HTTPClient.md",
"exercise_id": "c5456368050f4ad1bdce9e19548e5c1a",
"notebook_enable": true
}
\ No newline at end of file
# HTTPClient
下列语句皆为使用HTTPClient获取网页的流程之一,其中不正确的是:
## 答案
```java
HttpResponse.BodyHandler<String> bodyHandler = HttpResponse.BodyHandlers;
```
## 选项
### A
```java
String url = "https://www.baidu.com";
HttpClient client = HttpClient.newBuilder().build();
```
### B
```java
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create(url))
.header("Content-Type", "text/html")
.GET()
.build();
```
### C
```java
HttpResponse<String> response = client.send(request, bodyHandler);
if (response.statusCode() == 200) {
System.out.println(response.body());
}
```
{
"type": "code_options",
"author": "clong",
"source": "WebSocket.md",
"exercise_id": "dac563065d504db1bdca92dba611f4cb",
"notebook_enable": true
}
\ No newline at end of file
# WebSocket
`WebSocket`可以实现服务端对客户端的推送,避免客户端轮询,造成带宽资源浪费。以下关于`WebSocket`的说法错误的是:
## 答案
```
WebSockt与HTTP都是基于TCP的,因此url也是以HTTP开头
```
## 选项
### A
```
WebSocket基于TCP协议
```
### B
```
WebSocket是双向的,即全双工协议
```
### C
```
WebSocket是一种有状态的协议
```
{
"node_id": "java-dd60957a0a7f4155a68aea7c6807d504",
"keywords": ["websocket", "get", "post", "delete", "put", "请求"],
"children": [
{
"发送同步GET请求": {
"keywords": [],
"children": [],
"node_id": "java-01931200f6684a0bba54c8fe79070301",
"title": "发送同步GET请求"
}
},
{
"发送带请求体的请求": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"title": "发送带请求体的请求"
}
},
{
"发送异步请求": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"title": "发送异步请求"
}
},
{
"WebSocket客户端支持": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"基于WebSocket的多人实时聊天": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
}
],
"export": ["HTTPClient.json", "WebSocket.json"],
"title": "Java 11标准化的HTTP Client"
}
\ No newline at end of file
{
"type": "code_options",
"author": "clong",
"source": "Instanceof.md",
"exercise_id": "d2b56cc9a32a4b9993ab41bad65892b2",
"notebook_enable": true
}
\ No newline at end of file
# Instanceof
已知Person是Man的父类,以下结果为True的是:
## aop
### before
```java
Man man = new Man();
Person person = new Person();
```
## 答案
```
man instanceof Person
```
## 选项
### A
```java
man.getClass.equals(Person.class)
```
### B
```java
Man.class.isInstance(person)
```
### C
```java
person.getClass() == Man.class
```
{
"node_id": "java-feca89c3fb9e4bcaba3f1f95e8ad4753",
"keywords": ["类型"],
"children": [],
"export": ["Instanceof.json"],
"title": "instanceof与Class的等价性"
}
\ No newline at end of file
{
"type": "code_options",
"author": "clong",
"source": "Reflect.md",
"exercise_id": "a37be7bf155943179abd1d1c3efb7064",
"notebook_enable": true
}
\ No newline at end of file
# Reflect
下列关于JAVA反射的说法正确的是:
## aop
### before
```java
```
## 答案
```
以上说法均正确
```
## 选项
### A
```
反射机制作用在程序运行状态
```
### B
```
能动态获取类的属性及方法并能进行调用
```
### C
```
反射首先要获取类的Class类对象
```
{
"type": "code_options",
"author": "clong",
"source": "ReflectTest.md",
"exercise_id": "23057a3a31b0428e8ed7c44b5328d48a",
"notebook_enable": true
}
\ No newline at end of file
# ReflectTest
以下程序是关于反射的一个例子,程序的控制台打印为:
```java
public class Reflect {
public static void main(String[] args) throws NoSuchMethodException, InvocationTargetException, InstantiationException, IllegalAccessException {
Class clazz = Student.class;
Constructor con = clazz.getConstructor(String.class, Integer.class);
Student student1 = (Student) con.newInstance("小铭", 24);
Student student2 = new Student("小铭", 24);
System.out.println(student2 == student1);
System.out.println(student2.equals(student1));
}
}
```
## aop
### before
```java
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
class Student {
private String name;
private Integer age;
public Student() {}
public Student(String name, Integer age) {
this.name = name;
this.age = age;
}
@Override
public String toString() {
return "Student{" +
"name='" + name + '\'' +
", age=" + age +
'}';
}
}
```
## 答案
```
false
false
```
## 选项
### A
```
false
true
```
### B
```
true
false
```
### C
```
true
true
```
{
"node_id": "java-42b26ca8a2384dcfb02fca6e159ace67",
"keywords": ["annotation", "标注"],
"children": [
{
"类方法抽取器": {
"keywords": [],
"children": [],
"node_id": "java-aa383e03d51a4ea588ee1b04192ab556",
"title": "类方法抽取器"
}
},
{
"Class类与Java反射": {
"keywords": [],
"children": [
{
"访问构造方法": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"title": "访问构造方法"
}
},
{
"访问成员变量": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"访问方法": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
}
],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8",
"title": "Class类与Java反射"
}
},
{
"使用Annotation功能": {
"keywords": [],
"children": [
{
"定义Annotation类型": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"访问Annotation信息": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
}
],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"声明异常入门": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"资源": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"利用反射分析类的能力": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"使用反射在运行时分析": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"使用反射编写泛型数组": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"访问字段": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"调用方法": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"调用构造方法": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
},
{
"获取继承关系": {
"keywords": [],
"children": [],
"node_id": "569d5e11c4fc5de7844053d9a733c5e8"
}
}
],
"export": ["Reflect.json", "ReflectTest.json"],
"title": "反射:运行时类信息"
}
\ No newline at end of file
{
"type": "code_options",
"author": "clong",
"source": "DynamicProxy.md",
"exercise_id": "3825ea2504a34a1fbd3f40090cb7a6ca",
"notebook_enable": true
}
\ No newline at end of file
# DynamicProxy
下列关于JAVA动态代理的说法正确的是:
## 答案
```
以上说法均正确
```
## 选项
### A
```
为对象提供一个代理,控制对对象的访问
```
### B
```
动态代理有两种实现方式:JDK动态代理实现和CGlib字节码技术实现
```
### C
```
JDK动态代理只能代理接口而不能代理类
```
{
"type": "code_options",
"author": "clong",
"source": "DynamicProxyTest.md",
"exercise_id": "675c2c4dcb41423095d3f6dcdae93aab",
"notebook_enable": true
}
\ No newline at end of file
# DynamicProxyTest
以下程序是关于动态代理的一个例子,1和2处填入正确的是:
```java
interface Person {
void speak(String text);
}
public class DynamicProxyTest {
public static void main(String[] args) {
InvocationHandler handler = new InvocationHandler() {
@Override
public Object invoke(Object proxy, Method method, Object[] args) {
if (method.getName().equals("speak")) {
System.out.println("准备");
System.out.println(args[0]);
System.out.println("结束");
}
return null;
}
};
Person person = (Person) Proxy.newProxyInstance(
1,
2,
handler);
person.speak("你好,很高兴认识你。");
}
}
```
## 答案
```
Person.class.getClassLoader()
new Class[] { Person.class }
```
## 选项
### A
```
Person.getClassLoader()
Person.class
```
### B
```
Person.class.getClassLoader()
Person.getClass()
```
### C
```
Person.getClassLoader()
new Class[] { Person.class }
```
{
"node_id": "java-f7be740717c442c4a489a8c8d675f38c",
"keywords": ["proxy"],
"children": [],
"export": ["DynamicProxy.json", "DynamicProxyTest.json"],
"title": "动态代理"
}
\ No newline at end of file
{
"type": "code_options",
"author": "clong",
"source": "None.md",
"exercise_id": "669d00b9f4c6408db09e5eeead918286",
"notebook_enable": true
}
\ No newline at end of file
# 空对象
下列关于空对象的说法错误的是:
## 答案
```
构造空对象是java内置的
```
## 选项
### A
```
空对象,没有赋值过,但是却在内存中存在
```
### B
```
空对象能避免报空指针异常
```
### C
```
有时候还是要判断对象是否为空对象
```
{
"node_id": "java-dec42155c7904f7e9d00a37b5013470d",
"keywords": ["空对象"],
"children": [
{
"模拟对象与桩": {
"keywords": [],
"children": [],
"node_id": "java-0109d4ae23934645bc817fd2ac423854",
"title": "模拟对象与桩"
}
}
],
"export": ["None.json"],
"title": "空对象"
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册