运行Java语句System.out.println(Math.sin(Math.PI/2));得到的结果为()。
第1题:
A.“hello”
B.“good-bye”
C.“hello”“good-bye”
D.代码不能编译
第2题:
请阅读下面程序 import java.io.*; public class ExceptionCatch { public static void main(String args[]) { try{ FilelnputStream fis=new FilelnputStream("text"); System.out.println("content of text is:"); } catch(FileNotFoundException e) { System.out.println(e); System.out.println("message:"+e.getMessageO); e.printStackTrace(System.out); }____{ System.out.println(e); } } } 为保证程序正确运行,程序中下划线处的语句应是
A.catch(FilelnputStream fis)
B.e.printStackTrace()
C.catch(IOException e)
D.System.out.println(e)
第3题:
A.MyExample
B.Aptech
C.Online
D.产生异常:"java.lang.ArrayIndexOutOfBoundsException"
第4题:
下列关于Java对import语句规定的叙述中,错误的是
A.在Java程序中import语句可以有多个
B.在Java程序中import语句可以没有
C.在Java程序中import语句必须有一个
D.在Java程序中import语句必须引入在所有类定义之前
第5题:
请完成下列Java程序:实现打印出自己的源文件的功能。
注意:请勿改动main()主方法和其他已有语句内容,仅在下划线处填入适当的语句。
import java.io.*;
import java.util.StringTokenizer;
public class ex27_2{
public static void main(String args[])throws IOException{
FileInputStream fis=new FileInputStream("ex27_2.java");
DataInputStream dis=new DataInputStream(fis);
String str=null;
while(true){
__________________;
if(str==null){
__________________;
}
StringTokenizer st=new StringTokenizer(str);
while(st.hasMoreTokens()){
System.out.print(st.nextToken()+ " " );
}
System.out.println();
}
}
}
第6题:
( 21 )请阅读下面程序
import java.io. *;
public class ExceptionCatch{
public static void main ( String args[] ){
try {
FileInputStream fis=new FilelnputStream ( "text" ) ;
System.out.pfntln ( "content of text is : ” ):
} catch ( FileNotFoundException e ){
System.out.println ( e ) ;
System.out.println ( "message:"+e.getMessageQ ) ;
e.printStackTrace ( System.out ) ;
}____________;
{
System.out.println ( e ) ;
}
}
}
为保证程序正确运行,程序中下划线处的语句应是
A ) catch ( Fiie put eam s )
B ) e printStackTrace ()
C) catch ( IOException e )
D) System.out.printin ( e )
第7题:
publicclassThreads2implementsRunnable{publicvoidnun(){System.out.println(”run.”);thrownewRuntimeException(”Problem”);}publicstaticvoidmain(String[]args){Threadt=newThread(newThreads2());t.start();System.out.println(”Endofmethod.”);}}Whichtwocanberesults?()
A.java.lang.RuntimeException:Problem
B.run. java.lang.RuntimeException:Problem
C.Endofmethod. java.lang.RuntimeException:Problem
D.Endofmethod. run.java.lang.RuntimeException:Problem
E.run. java.lang.RuntimeException:ProblemEndofmethod.
第8题:
在Java中,类Animal中的方法printA()定义如下:publicvoidprintA(){inta=10;intresult=10%3;System.out.println(result);}在类Dog中方法printA()定义如下:publicvoidprintA(){inta=10;System.out.println(a/3);}Dog类的定义如下:classDogextendsAnimal{…}.Animalanimal=newDog();animal.printA();以上语句输出为()。
A.0
B.1
C.2
D.3
E.3.3333
第9题:
设有下面的两个类定义: class AA{ void Show ( ) {System.out.println ("I Like Java"):} } class BB extends AA} void Show ( ) {System.out.println ("I like C++"); } } 则顺序执行如下语句后输出的结果为( )。 AA a; BB b; a.Show (); b.Show ();
A.I Like Java I Like C++
B.I Like C++ I Like Java
C.I Like Java I Like Java
D.I Like C++ I Like C++
第10题:
在程序中,用户输入一个文件名,根据用户输入显示相应文件的信息。
注意:请勿修改main()主方法和其他已有语句内容,仅在横线处填入适当语句。
______java.io.*;
public class basic
{
public static void main(String[] args)
{
InputStreamReader reader;
BufferedReader in;
System.out.println("请输入文件名: ");
try
{
reader=new InputStreamReader(______);
in=new BufferedReader(reader);
String filename=in.readLine();
File file=new File(filename);
System.out.println("文件名:"+file.______);
System.out.println("路径:"+file.getAbsolutePath());
System.out.println("大小:"+file.length());
}
catch(Exception e)
{
e.printStackTrace();
}
}
}