OCP Java17 SE Developers 复习题12

============================  答案  ==============================

================================================================

================================================================

E.  Modules are required to have a module-info.java file at the root directory of the module. Option E matches this requirement.

============================  答案  ==============================

================================================================

================================================================

B.  Options A, C, and E are incorrect because they refer to directives that don't exist. The exports directive is used when allowing a package to be called by code outside of the module, making option B the correct answer. Notice that options D and F are incorrect because of requires.

============================  答案  ==============================

================================================================

================================================================

G.  The -m or --module option is used to specify the module and class name. The -p or --module-path option is used to specify the location of the modules. Option D would be correct if the rest of the command were correct. However, running a program requires specifying the package name with periods (.) instead of slashes. Since the command is incorrect, option G is correct.

============================  答案  ==============================

================================================================

================================================================

D.  A service consists of the service provider interface and logic to look up implementations using a service locator. This makes option D correct. Make sure you know that the service provider itself is the implementation, which is not considered part of the service.

============================  答案  ==============================

================================================================

================================================================

E, F.  Automatic modules are on the module path but do not have a module-info.java file. Named modules are on the module path and do have a module-info. Unnamed modules are on the classpath. Therefore, options E and F are correct.

============================  答案  ==============================

================================================================

================================================================

A, F.  Options C and D are incorrect because there is no use directive. Options A and F are correct because opens is for reflection and uses declares that an API consumes a service.

============================  答案  ==============================

================================================================

================================================================

A, B, E.  Any version information at the end of the JAR filename is removed, making options A and B correct. Underscores (_) are turned into dots (.), making options C and D incorrect. Other special characters like a dollar sign ($) are also turned into dots. However, adjacent dots are merged, and leading/trailing dots are removed. Therefore, option E is correct.

============================  答案  ==============================

================================================================

================================================================

A, D.  A cyclic dependency is when a module graph forms a circle. Option A is correct because the Java Platform Module System does not allow cyclic dependencies between modules. No such restriction exists for packages, making option B incorrect. A cyclic dependency can involve two or more modules that require each other, making option D correct, while option C is incorrect. Finally, option E is incorrect because unnamed modules cannot be referenced from an automatic module.

============================  答案  ==============================

================================================================

================================================================

F.  The provides directive takes the interface name first and the implementing class name second and also uses with. Only option F meets these two criteria, making it the correct answer.

============================  答案  ==============================

================================================================

================================================================

B, C.  Packages inside a module are not exported by default, making option B correct and option A incorrect. Exporting is necessary for other code to use the packages; it is not necessary to call the main() method at the command line, making option C correct and option D incorrect. The module-info.java file has the correct name and compiles, making options E and F incorrect.

============================  答案  ==============================

================================================================

================================================================

D, G, H.  Options A, B, E, and F are incorrect because they refer to directives that don't exist. The requires transitive directive is used when specifying a module to be used by the requesting module and any other modules that use the requesting module. Therefore, dog needs to specify the transitive relationship, and option G is correct. The module puppy just needs requires dog, and it gets the transitive dependencies, making option D correct. However, requires transitive does everything requires does and more, which makes option H the final answer.

============================  答案  ==============================

================================================================

================================================================

A, B, C, F.  Option D is incorrect because it is a package name rather than a module name. Option E is incorrect because java.base is the module name, not jdk.base. Option G is wrong because we made it up. Options A, B, C, and F are correct.

============================  答案  ==============================

================================================================

================================================================

D.  There is no getStream() method on a ServiceLoader, making options A and C incorrect. Option B does not compile because the stream() method returns a list of Provider interfaces and needs to be converted to the Unicorn interface we are interested in. Therefore, option D is correct.

============================  答案  ==============================

================================================================

================================================================

C.  The -p option is a shorter form of --module-path. Since the same option cannot be specified twice, options B, D, and F are incorrect. The --module-path option is an alternate form of -p. The module name and class name are separated with a slash, making option C the answer. Note that x-x is legal because the module path is a folder name, so dashes are allowed.

============================  答案  ==============================

================================================================

================================================================

B.  A top-down migration strategy first places all JARs on the module path. Then it migrates the top-level module to be a named module, leaving the other modules as automatic modules. Option B is correct as it matches both of those characteristics.

============================  答案  ==============================

================================================================

================================================================

A.  Since this is a new module, you need to compile it. However, none of the existing modules needs to be recompiled, making option A correct. The service locator will see the new service provider simply by having that new service provider on the module path.

============================  答案  ==============================

================================================================

================================================================

E.  Trick question! An unnamed module doesn't use a module-info.java file. Therefore, option E is correct. An unnamed module can access an automatic module. The unnamed module would simply treat the automatic module as a regular JAR without involving the module.info file.

​​​​​​​

============================  答案  ==============================

================================================================

================================================================

D.  The jlink command creates a directory with a smaller Java runtime containing just what is needed. The JMOD format is for native code. Therefore, option D is correct.

============================  答案  ==============================

================================================================

================================================================

E.  There is a trick here. A module definition uses the keyword module rather than class. Since the code does not compile, option E is correct. If the code did compile, options A and D would be correct.

============================  答案  ==============================

================================================================

================================================================

A.  When running java with the -d option, all the required modules are listed. Additionally, the java.base module is listed since it is included automatically. The line ends with mandated, making option A correct. The java.lang is a trick since it is a package that is imported by default in a class rather than a module.

============================  答案  ==============================

================================================================

================================================================

H.  This question is tricky. The service locator must have a uses directive, but that is on the service provider interface. No modules need to specify requires on the service provider since that is the implementation. Since none are correct, option H is the answer.

============================  答案  ==============================

================================================================

================================================================

A, F.  An automatic module exports all packages, making option A correct. An unnamed module is not available to any modules on the module path. Therefore, it doesn't export any packages, and option F is correct.

============================  答案  ==============================

================================================================

================================================================

E.  The module name is valid, as are the exports statements. Lines 4 and 5 are tricky because each is valid independently. However, the same module name is not allowed to be used in two requires statements. The second one fails to compile on line 5, making option E the answer.

============================  答案  ==============================

================================================================

================================================================

A.  Since the JAR is on the classpath, it is treated as a regular unnamed module even though it has a module-info.java file inside. Remember from learning about top-down migration that modules on the module path are not allowed to refer to the classpath, making options B and D incorrect. The classpath does not have a facility to restrict packages, making option A correct and options C and E incorrect.

============================  答案  ==============================

================================================================

================================================================

A, C, D.  Options A and C are correct because both the consumer and the service locator depend on the service provider interface. Additionally, option D is correct because the service locator must specify that it uses the service provider interface to look it up.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/309490.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

IOS 短信拦截插件

在使⽤iOS设备的时候, 我们经常会收到1069、1065开头的垃圾短信, 如果开了iMessage会更严重, 各种乱七⼋糟的垃圾信息会时不时地收到。 从iOS11开始, ⼿机可以⽀持恶短信拦截插件了. 我们可以通过该插件添加⼀些规则通过滤这些不需要的信息. ⼀. 使⽤xcode新建⼀个项⽬ 【1】…

网络篇01 | 入门篇

网络篇01 | 入门篇 01 各层协议目录[网络篇02 | 应用层 kcp(王者荣耀)](https://blog.csdn.net/qiushily2030/article/details/135835946)[网络篇03 | 应用层 quic](https://blog.csdn.net/qiushily2030/article/details/136192481)[网络篇04 | 应用层 m…

【Ubuntu】 Github Readme导入GIF

1.工具安装 我们使用 ffmpeg 软件来完成转换工作1.1 安装命令 sudo add-apt-repository ppa:jonathonf/ffmpeg-3sudo apt-get updatesudo apt-get install ffmpeg1.2 转换命令 (1)直接转换命令: ffmpeg -i out.mp4 out.gif(2) 带参数命令&…

系统架构最佳实践 -- 统一身份认证系统

目录 1.系统架构设计: 2.用户认证与授权: 3.用户身份管理: 4.安全性保障: 5.日志记录与审计: 6.高可用性与容错性: 7.用户体验优化: 随着互联网的快速发展和应用的普及,人们在…

嵌入式学习day16-22(2024.04.06-13)

文章目录 C语言网络编程socket主机与网络字节序转换inet_addr、inet_aton(ip转换)inet_ntoa 网络字节序转换为IP字符串端口转换为网络字节序网络字节序转换为端口atoi (字符串转换为整数) UDP通信流程UDP多进程并发服务器服务端客…

Vue指令案例

通过Vue完成表格数据的渲染展示 最终结果为&#xff1a; <!DOCTYPE html> <html lang"en"><head><script src"vue.js">//引入vue文件</script><meta charset"UTF-8"><meta name"viewport" c…

设计模式系列:责任链模式

简介 责任链模式是一种行为型设计模式&#xff0c;它允许你将请求沿着处理者链进行发送。每个处理者都可以对请求进行处理&#xff0c;或者将其传递给链上的下一个处理者。责任链模式主要应用于面向对象编程中&#xff0c;特别是当系统中的对象需要根据其属性来决定如何处理请…

DNS正反向解析

1.先连接X-shell 主服务器&#xff1a;192.168.32.168&#xff08;server&#xff09; 从服务器&#xff1a;192.168.32.169&#xff08;node&#xff09; 2.给主从服务器做准备工作 [rootserver ~]# setenforce 0 setenforce: SELinux is disabled [rootserver ~]# systemc…

基于SpringBoot+Mybatis框架的私人影院预约系统(附源码,包含数据库文件)

基于SpringBootMybatis框架的私人影院预约系统&#xff0c;附源码&#xff0c;包含数据库文件。 非常完整的一个项目&#xff0c;希望能对大家有帮助哈。 本系统的完整源码以及数据库文件都在文章结尾处&#xff0c;大家自行获取即可。 项目简介 该项目设计了基于SpringBoo…

季节更迭 关爱不变 | 鲁南制药四季守护您的健康生活

春天&#xff0c;万物复苏的季节&#xff0c;一切都充满了生机和活力。在春日的阳光下&#xff0c;鲜花盛开&#xff0c;绿叶茂盛&#xff0c;鸟儿欢歌&#xff0c;蝴蝶翩翩起舞。我们的身体也需要特别的关爱和养护&#xff0c;保持健康和活力&#xff0c;更好地迎接每一次季节…

冯喜运:4-15周一黄金原油行情分析及操作建议

【 黄金消息面分析】&#xff1a;周五(4月12日)美盘时段&#xff0c;黄金价格再创历史新高一度突破2420美元关口&#xff0c;最高触及2431美元/盎司&#xff0c;尽管相对强弱指数(RSI)显示超买状态&#xff0c;但随着以色列和伊朗之间的地缘政治紧张局势升级&#xff0c;投资者…

Object和Objects

Object Object是Java中的顶级父类.所有的类都直接或间接的继承Object类. Object类中的方法可以被所有子类访问,所以我们要学习Object类和其中的方法. Object的构造方法: Object的成员方法 public class test {public static void main(String[] args) {//1.toString 返回对象…

跨平台桌面应用 Electron 入门学习

本文章主要为该视频的学习笔记&#xff0c;如果侵权会速删。 Electron 01 课程介绍_哔哩哔哩_bilibiliElectron 01 课程介绍, 视频播放量 3046、弹幕量 0、点赞数 75、投硬币枚数 43、收藏人数 179、转发人数 2, 视频作者 极客丶张德龙, 作者简介 当你的能力还不足以撑起自己的…

蓝桥杯算法题:练功

【问题描述】 小明每天都要练功&#xff0c;练功中的重要一项是梅花桩。 小明练功的梅花桩排列成 n 行 m 列&#xff0c;相邻两行的距离为 1&#xff0c;相邻两列的距离也为 1。 小明站在第 1 行第 1 列上&#xff0c;他要走到第 n 行第 m 列上。小明已经练了一段时间&#xff…

【系统分析师】数据库部分

文章目录 1、数据库模式2、数据库设计过程2.1ER模型 3、关系代数 ☆5、规范化理论☆5.1 非规范存在的问题5.2 相关概念5.3范式5.3.1 第一范式-1NF5.3.2 第二范式-2NF5.2.3 第三范式5.2.4 BC范式 5.4 函数依赖分解5.4.1保持函数依赖分解5.4.2 无损分解 5.5 Armstong公理系统 6、…

物联网实战--驱动篇之(七)RTC时钟(DS1302)

目录 一、RTC简介 二、DS1302介绍 三、初始化 四、字节读写 五、功能函数 一、RTC简介 实时时钟&#xff0c;简称RTC&#xff0c;这个在STM32的外设里也有&#xff0c;不过STM32F1系列的RTC实际上只有一个计数器功能&#xff0c;如果需要年月日要自己写软件计算 &#xff…

数字IC/FPGA(时钟简介)

本文主要介绍以下几点&#xff1a; 什么是时钟什么是外部时钟和内部时钟时钟偏斜skew、时钟延迟delay和时钟抖动jitter的定义、三者的区别时钟抖动、时钟偏斜、时钟延迟会引起或不会引起什么情况布线方式的影响&#xff0c;正偏差和负偏差的好处和坏处什么是同步电路什么是异步…

二叉树经典OJ题(2)

一、根据二叉树创建字符串 . - 力扣&#xff08;LeetCode&#xff09; class Solution { public://前序遍历&#xff1a;根 左 右//左子树为空&#xff0c;右子树不为空的时候&#xff0c;不能省略左//左不为空&#xff0c;右子树为空的时候&#xff0c;可以省略右//都为空&am…

【springCloud】版本学习

Spring Cloud介绍 官网地址&#xff1a;https://spring.io/projects/spring-cloud Spring Cloud 是一个基于 Spring Boot 的微服务架构解决方案&#xff0c;它提供了一系列工具和模式来帮助开发者构建分布式系统。Spring Cloud 的组件和模式包括配置管理、服务发现、断路器、…

【Linux】tcpdump P3 - 过滤和组织返回信息

文章目录 基于TCP标志的过滤器格式化 -X/-A额外的详细选项按协议(udp/tcp)过滤低详细输出 -q时间戳选项 本文继续展示帮助你过滤和组织tcpdump返回信息的功能。 基于TCP标志的过滤器 可以根据各种TCP标志来过滤TCP流量。这里是一个基于tcp-ack标志进行过滤的例子。 # tcpdump…