题目示例
下列程序的输出结果是______。 public class Test { public static void main(String[] args){ int[] array={2,4,6,8,10}; int size=6; int result=-1; try { for(int i=0;i<size && result==-1;i++) if(array[i]==20) result=i; } catch(ArithmeticException e){ System.out.println("Catch---1"); } catch(ArrayIndexOutOfBoundsExce
- Catch---1
- Catch---2
- Catch---3
- 以上都不对
提供showDocument()方法,使Applet能够请求浏览器访问特定URL的类是______。
- Applet
- AppletContext
- JApplet
- URL
阅读下列代码 public class Test{ public static void main (String args[]){ System.out.println((2<0)?10:8); } } 其运行结果是______。
- 2
- 0
- 10
- 8
在使用interface声明一个接口时,用下面______修饰符修饰该接口时,该接口被使用的范围最广。
- private
- protected
- private protected
- public
若有语句String s="java",则查找s中字母a最后出现的位置的语句是______。
- s.lastIndexOf('a');
- charAt(2);
- s.indexOf('a');
- indexOf(s,'a');
若已有如下类定义: class Animal { } class Cat extends Animal { } class PetCat extends Cat { } 则下列语句中正确的是______。
- Cat cat=new Animal();
- PetCat cat=new Animal();
- Animal animal=new PetCat();
- PetCat cat=new Cat();
下列程序的运行结果是______。 public class MyTest{ public static void main (String[] args){ int i=0,j=0; for(j=1;j<100;j++){ i+=j; } System.out.println(j); } }
- 1
- 99
- 100
- 4950
阅读下列代码 public class Test2005 { public static void main(String args[]) { System.out.println(~(0xa5)&0xaa); } } 其运行结果是______。
- 0xa5
- 10
- 0x50
- 0xaa