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;)
if (array[i] == 20)
result = i;
} catch (ArithmeticException e)
{ System.out.println("Catch---
1");
}catch(ArrayIndexOutOfBoundsException e)
{ System.out.println("Catch---2");
} catch (Exception e)
{ System.out.println("Catch---3");
}
}
}
int data=0;
char k='a',p='f' data = p-k;System.out.printlln(data);
public class Test {
public static void main(String args[ ] )
{System.out.println((2<0) ? 10:8);
}
}
其运行结果是()。
public class Test extends Thread{
public static void main(String[ ] args){
Thread t=new Thread( );
t.start( );
}
public void run( ){
System.out.println(“Hello”);
}
}
import java.io.*;
public class Test{
public static void main(String[ ] args){
try{
RandomAccessFile raf = new RandomAccessFile(“test.dat”,“r”);
System.out.println(“test.dat”);
}
catch(IOException ex){
System.out.println(“exception”);
}
}
}
class Shape{
public Shape( ){
System.out.print(“Shape”);
}
}
class Circle extends Shape{
public Circle ( ){
System.out.print(“Circle”);
}
}
public class Test{
public static void main(String[ ] args){
Shape dd = new Circle( );
}
}
在下画线处,应填入的正确选项是() 。
public class VariableUse{
public static void main(String[] args){
int a;
if(a==8){
int b=9;
System.out.println("a"="+a);
System.out.println("b="+b);
}
System.out.println("a="+a);
System.out.println("b="+b);
}}
该程序在编译时的结果是()。
import javax.swing.*;
import java.awt.*;
public class Test{
public static void main (String [ ] args){
JFrame f = new JFrame( );
JPanel p = new JPanel( );
f.setLayout(new BorderLayout( ));
f.getContentPane( ).add(p,"Center”);
p.setBackground(Color.blue);
f.setVisible(true);
f.setSize(200,200);
}
}
public class MyCase{
public static void main(String[ ] args){
char a = ’d’, b = ’c’, c = ’a’;
String d = “abc”;
System.out.println(a + “b” + c + d);
}
}
40题 | 被引用968次