更多"在Java中,下列代码将输出()。  1. &en"的相关试题:
[单项选择] 分析下列java代码 Class A{ Public static void main(String[] args){ Method(); } Static void method(){ try{ System.out.println(“hello”) }finally{ System.out.println(“good-bye”); } } } 编译运行后,输出结果是()
A. “hello”
B. “good-bye”
C. “hello”“good-bye”
D. 代码不能编译
[单项选择] 分析下列Java代码: class A { public static void main(String[] args) { method(); } static void method() { try { System.out.println("Hello"); System.exit(0); } finally { System.out.println("good-bye"); } } } 编译运行后,输出结果是()。
A. "Hello"
B. "good-bye"
C. "Hello"后面是"good-bye"
D. 代码不能编译
[单项选择] 考虑下列Java代码: Classc A{ Public static void main(String []args){ Try{ System.out.println(“hello,world”) } } } 其中错误的是()。
A. 没有catch或finally块
B. 没有抛出异常的代码不能出现在try代码块内
C. 如果没有catch块而使用try,main()会总是抛出异常.
D. class A 没有throws IOException
[单项选择] 考虑下列Java代码: class A { public static void main(String[] args) { try { System.out.println("Hello, World!"); } } } 其中的错误是()。
A. 没有catch或finally块
B. 没有抛出异常的代码不能出现在try代码块内
C. 如果没有catch块而使用try,main()会总是抛出异常.
D. class A 没有throws IOException
[多项选择] 给出下列java源代码: //Point x Public class Interesting{} 在源代码//point x处添加()能符合java语法
A. import java.awt.*
B. package local.util
C. class MoreInteresting{}
D. protected class MoreInteresting{}
[单项选择] 研究下面的Java代码: public class testException{ public static void main(String args[]){ int a[]={0,1,2,3,4}; int sum=0; try{ for(int i=1;i<6;i++) sum=sum+a[i]; System.out.println("sum="+sum); } catch(ArrayIndexOutOfBoundsException ){ System.out.println("数组越界"); } finally{ System.out.println("程序结束");} } } 输出结果将是()。
A. 10 数组越界 程序结束
B. 10 程序结束
C. 数组越界 程序结束
D. 程序结束
[单项选择] In a Java EE messaging application, one MDB is consuming a lot of memory at high traffic. What configuration should you use to prevent possible out-of-memory error at high traffic and at the same time not losing messages?()
A. Configure a Work Manager for the MDB with a Maximum Thread Constraint.
B. Configure a Work Manager for the MDB with a Minimum Thread Constraint.
C. Configure a Work Manager for the MDB with a Maximum Thread Constraint and a Capacity Constraint.
D. Configure a Work Manager for the MDB with a Minimum Thread Constraint and a Capacity Constraint.
E. Configure a Work Manager for the MDB with both a Maximum Thread Constraint and Minimum Thread Constraint.
[多项选择] You deployed a Java EE Shared Library and want to use it from an application that is also deployed on the same cluster. Which two manifest attributes must be specified at a minimum with corresponding values in the deployment descriptor of the application that requires?()
A. Implementation-Version
B. Specification-Version
C. Extension-Name
D. Specification-Vendor
E. Implementation-Vendor
[单项选择] 研究下面的Java代码: switch (x) { case 1: System.out.println(1); case 2: case 3: System.out.println(3); case 4: System.out.println(4); } 当x=2时,运行结果是()。
A. 没有输出任何结果
B. 输出结果为3
C. 输出结果是3和4
D. 输出结果是1、3和4
[单项选择] class java { public static void main(String [] java) { for (int Java = 1; Java 〈 java.length; Java++) System.out.print("java "); } } 和命令行: java java java java java 结果为:()
A. java
B. java java
C. java java java
D. 编译失败
[单项选择] 现有: -f是一个对java .io.File实例的合法引用 - fw足‘个对java.io.FileWriter实例的合法引用 - bw足一个对java.io.BufferedWriter实例的合法引用 以下哪一项无效?()
A. PrintWriter prtWtr = new PrintWriter (f);
B. PrintWriter prtWtr = new PrintWriter( fw);
C. PrintWriter prtWtr = new PrintWriter(bw):
D. BufferWriter bufWtr = new BufferedWritr(f);
E. BufferWriter bufWtr = new BufferedWriter(fw);
F. BufferWriter bufWtr = new BufferedWriter (bw):
[单项选择] 在J2EE中,有如下代码在Servlet1.Java中 Import javax.servlet.*; Import javax.servlet.http.* Import java.io.IOException; Import java.io.PrintWriter; Public class Servlet1 extends HttpServlet{ Public void init () throw ServletException {} Public void service(HttpServletRequest request, HttpServletResponce response) throws ServletException,IOException{ PrintWriter out=response.getWriter(); Out.println(“hello!”); } } 假如编译Servlet要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下成熟正确的是()
A. 编译该晚间时会提示缺少doGe()t或者doPost(),编译不能够成功通过
B. 编译后,把Serlvet.cass放在正确的位置,在浏览器中查看该Servlet1,会看到输出文在:“hello!”
C. 编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看不到任何输出的文字
D. 编译后,把Servlet.class放在正确的位置,在浏览器中查看该Servlet1,却看到产生运行时错误的出错信息
[单项选择] ClassOne.java package com.abc.pkg1; public class ClassOne { private char var = ‘a‘; char getVar() {return var;} } ClassTest.java package com.abc.pkg2; import com.abc.pkg1.ClassOne; public class ClassTest extends ClassOne { public static void main(Stringargs) { char a = new ClassOne().getVar(); char b = new ClassTest().getVar(); } } What is the result?()
A. Compilation will fail.
B. Compilation succeeds and no exceptions are thrown.
C. Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.
D. Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.
[多项选择] 现有如下命令行: java -showversion ShowVersion ShowVERSION SHOWVERSION 哪三个是对的?()
A. 这是一个合法调用
B. 这是一个非法调用
C. 该调用包含一个选项
D. 该调用包含两个参数
[多项选择] Given a file GrizzlyBear.java: 1. package animals.mammals; 2. 3. public class GrizzlyBear extends Bear { 4. void hunt() { 5. Salmon s = findSalmon(); 6. s.consume(); 7. } 8. } and another file, Salmon.java: 1. package animals.fish; 2. 3. public class Salmon extends Fish { 4. void consume() { /* do stuff */ } 5. } Assume both classes are defined in the correct directories for theft packages, and that the Mammal class correctly defines the findSalmon() method. Which two changes allow this code to compile correctly?()
A. add public to the start of line 4 in Salmon.java
B. add public to the start of line 4 in GrizzlyBear.java
C. add import animals.mammals.*; at line 2 in Salmon.java
D. add import animals.fish.*; at line 2 in GrizzlyBear.java
E. add import animals.fish.Salmon.*; at line 2 in GrizzlyBear.java
F. add import animals.mammals.GrizzlyBear.*;at line 2 in Salmon.java
[单项选择] 执行以下代码会输出什么结果?() public class Test { StringgetStr(String s){ return s + “hello”; } public static void main(String arg[]) { Test t= new Test(); System.out.println(t.getStr(“LiLei/n”)); } }
A. 编译报错
B. LiLei hello
C. LiLeihello
D. 无任何输出
[单项选择] ClassOne.java 1. package com.abc.pkg1; 2. public class ClassOne { 3. private char var = ‘a’; 4. char getVar() {return var;} 5. } ClassTest.java 1. package com.abc.pkg2; 2. import com.abc.pkg1.ClassOne; 3. public class ClassTest extends ClassOne { 4. public static void main(String[]args) { 5. char a = new ClassOne().getVar(); 6. char b = new ClassTest().getVar(); 7. } 8. } What is the result?()
A. Compilation will fail.
B. Compilation succeeds and no exceptions are thrown.
C. Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.
D. Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.
[单项选择] 执行以下代码,输出结果的结果是? () public class Test{ public String[] ss = new String[5]; public static void main(String[] args){ System.out.println(ss[1]); } }
A. null
B. -1
C. 编译时出错
D. 运行时报错
[单项选择] 在j2ee中,有如下代码在servlet1.java中 Important javax.servelt.*; Important javax.servlet.http.* Import java.io.ioexception Import java.io.printwriter Public class servlet1 extends httpservlet{ Public void init() throws serveltexception{ } Public void service(httpservelt request request,httpserbletresponse response)throws servletexception,ioexception{ Printwriter out=response.getwriter(); Out.println(“hello”); } } 假如编译serblet 要具备的环境都已经建立好,现在用完全正确的命令编译该文件,对于以下陈述正确的是()
A. 编译该文件时会提示缺少doget()或者dopost()方法,编译不能够成功通过
B. 编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,会看到输出文字:“hello”
C. 编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看不到任何输出的文字
D. 编译后,把servlet1.class放在正确位置,在浏览器中查看该servlet1,却看到产生运行时错误的出差信息