logo - 刷刷题
下载APP
安阳师范学院―计算机应用技术―Java语言程序设计(一)
安阳师范学院―计算机应用技术―Java语言程序设计(一) - 刷刷题
题数
67
售价
¥5
收藏
分享
去刷题
章节目录
简介
...更多
题目预览
【简答题】
[1/67]class Ex extends Exception {} public class AlwaysFinally { public static vo...
参考答案:
您的答案: Entering first try block Entering second try block finally in 2nd try block Caught Ex in first try block finally in 1st try block
参考解析:
【简答题】
[2/67]class Ex0706Super { public String methodOne(String name) { System.out.print...
参考答案:
您的答案: 1. private String methodOne(String name),因为子类中定义的方法的访问权限不能低于父类 2. public String methodTwo(String name),methodTwo方法在其父类中被定义为final,故不能对其覆盖。 3. public final String methodThree(String name)。methodThree方法在其父类中被定义为static final的,所以不能对其进行覆盖
参考解析:
【简答题】
[3/67]public class Ex0708Class { private int method(int value) { System.out.print...
参考答案:
您的答案: public String method(int value) public static int method(int value) public final int method(int value) 因为已经定义了一个带int类型参数的method方法,以上三种写法都会导致程序提示说method方法重复定义。
参考解析:
【简答题】
[4/67]class Ex0707Super { public Ex0707Super(String name) { System.out.println("s...
参考答案:
您的答案: 1. Ex0707Sub的带String类型参数的构造函数缺少对父类构造函数的调用。 2. Ex0707Sub的不带参数的构造函数中的super()语句必须为构造函数的第一句。 3. Ex0707Sub subRef=superObj;错误,因为superObj的为subRef的父类产生的对象,这样赋值导致转型错误。应删除。
参考解析:
【简答题】
[5/67]分析下面程序,写出程序执行结果; public class Testp { public static void test(boolean test)...
参考答案:
您的答案: Before test(boolean):test=true In test(boolean):test=false After test(boolean):test=true
参考解析:
【简答题】
[6/67]public class Test { public static void main(String[] args) { int val; Strin...
参考答案:
您的答案: val=10 sb1=apples sb2=pears calling modify in modifying.... val=0 sb1=null sb2=pearstaste good return from modify val=10 sb1=apples sb2=pearstaste good
参考解析:
【简答题】
[7/67]下面程序是否有错?如果有错试标出错误位置并指出是何种错误。 public class AmIWrong implements Runnable { T...
参考答案:
} } 您的答案: 程序有错。run()方法作为接口中的方法缺省是public的, 题中缩小了范围。 改正如下: public class AmIWrong implements Runnable { Thread mt=Thread(this); mt.start(); public void run() { System.out.println(“I am alive now”); } }
参考解析:
【简答题】
[8/67]下面程序是否有错?如果有错试标出错误位置并指出是何种错误。 public static void main(String args[ ]) { try...
参考答案:
您的答案: 程序有错。捕获异常应将具体的异常类参数置前,题中将Exception类置前,将捕获所有异常,无法进入其他catch块。 改正如下: public static void main(String args[ ]) { try{ char ch=(char)System.in.read(); . . .//其他语句 } catch(IOException e) { System.out.println(e.toString()); } catch(Exception e) { return; } }
参考解析:
【简答题】
[9/67]下面程序是否有错?如果有错试标出错误位置并指出是何种错误。 interface MyInterface { void method1(); } abs...
参考答案:
您的答案: 程序有错,接口MyInterface中的方法method1()缺省是public的, 题中Child类在实现接口时缩小了范围。 改正如下: interface MyInterface { void method1(); } abstract class Parent implements MyInterface { } class Child extends Parent { public void method1() { System.out.println(“I am implemented now!”); } }
参考解析:
【简答题】
[10/67]下面程序是否有错?如果有错试标出错误位置并指出是何种错误。 class AmIWrong { int data1,data2; AmIWrong() ...
参考答案:
您的答案: 程序有错,构造函数重载this()语句应为第一个语句。 改正如下: class AmIWrong { int data1,data2; AmIWrong() { data1=-1; } AmIWrong(int d) { this(); data2=d; } }
参考解析: