[计算机类试卷]国家二级(JAVA)机试模拟试卷74及答案与解析.doc
《[计算机类试卷]国家二级(JAVA)机试模拟试卷74及答案与解析.doc》由会员分享,可在线阅读,更多相关《[计算机类试卷]国家二级(JAVA)机试模拟试卷74及答案与解析.doc(6页珍藏版)》请在麦多课文档分享上搜索。
1、国家二级( JAVA)机试模拟试卷 74及答案与解析 一、基本操作题( 30分) 1 请在每条横线处填写一个语句,使程序的功能完整,且输出结果为 91 1。 注意:请勿改动 main()主方法和其他已有的语句内容,仅在横线处填入适当的语句。 源程序文件代码清单如下: public class Outer public static void main (String args Outer i = new Outer(); i,taskInner(); public class Inner private int size; public void doSomething(int size) _
2、/访问局部变量 this. size+; /访问内部类的成员变量 _/访问外部类的成员变量 System.out.println(size+“ “+this.size+“ “+Outer.this.size); public void taskInner() _ k.doSomething(8); private static int size; 二、简单应用题( 40分) 2 本程序的功能是,根据用户输入的文件名,在相应的文件内容中查找匹配给定模式的字符串,并将这些字符串显示出来。模式串为 “href=“” 。请填写横线处的内容。 注意:请勿改动 main()主方法和其他已有语句内容,仅在横
3、线处填入适当语句。 import java.io.*; import java.util.regex.*; import javax.swing.*; public class Example2_10 public static void main(String argv) final String patternString = “hrefs*=s*(“*“|s )s*; String fileName ; try System. out. print ( “请输入 html 文件的文件名 : “); InputStreamReader in = new InputStreamReader(
4、System.in); BufferedReader imput = new BufferedReader(in); fileName = imput.readLine(); if(fileName.equals(“ “) return; StringBuffer buffer = new StringBuffer(); File file = new File(fileName); FileInputStream readfile = new FileInputStream(file); for(int c = 0; (c = readfile.read() != -1; ) buffer.
5、append(char)c); Pattern pattern = Ppile( _ Pattern.CASE_INSENSITIVE); Matcher matcher =_; while (marcher. find () int start = matcher.start(); int end = matcher.end(); String match = buffer.substring(start, end); System.out.println (match); catch (Exception excption) System. out.println (excption. g
- 1.请仔细阅读文档,确保文档完整性,对于不预览、不比对内容而直接下载带来的问题本站不予受理。
- 2.下载的文档,不会出现我们的网址水印。
- 3、该文档所得收入(下载+内容+预览)归上传者、原创作者;如果您是本文档原作者,请点此认领!既往收益都归您。
下载文档到电脑,查找使用更方便
2000 积分 0人已下载
下载 | 加入VIP,交流精品资源 |
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 计算机 试卷 国家 二级 JAVA 模拟 74 答案 解析 DOC
