网友您好, 请在下方输入框内输入要搜索的题目:
题目内容
(请给出正确答案)
单选题
现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?()
A
只在第11行
B
在第8行和第11行
C
在第5行、第8行和第11行
D
在第2行、第5行、第8行和第11行
参考答案
参考解析
解析:
暂无解析
更多 “单选题现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?()A 只在第11行B 在第8行和第11行C 在第5行、第8行和第11行D 在第2行、第5行、第8行和第11行” 相关考题
考题
阅读下列代码段,选出该代码段的正确文件名( )。 class A { void methodl() { System.out.println("methodl in class A"); } } public class B { void method2() { System.out.println("method2 in class B"); } public static void main(String args[]) { System.out.println("main in class B"); } }A.A.javaB.A.classC.B.classD.B.java
考题
interface A{int x = 0;}class B{int x =1;}class C extends B implements A {public void pX(){System.out.println(x);}public static void main(String[] args) {new C().pX();}}
考题
编程题:Class father{fathe() {}Class sun extends father{ son() {…..}Public static void main(){ son a=new father();}}此程序是否正确,为什么?
考题
1. public class Outer{ 2. public void someOuterMethod() { 3. // Line 3 4. } 5. public class Inner{} 6. public static void main( String[]argv ) { 7. Outer o = new Outer(); 8. // Line 8 9. } 10. } Which instantiates an instance of Inner?() A、 new Inner(); // At line 3B、 new Inner(); // At line 8C、 new o.Inner(); // At line 8D、 new Outer.Inner(); // At line 8
考题
1. public class Target { 2. private int i = 0; 3. public int addOne() { 4. return ++i; 5. } 6. } And: 1. public class Client { 2. public static void main(String[] args) { 3. System.out.println(new Target().addOne()); 4. } 5. } Which change can you make to Target without affecting Client?() A、 Line 4 of class Target can be changed to return i++;B、 Line 2 of class Target can be changed to private int i = 1;C、 Line 3 of class Target can be changed to private int addOne() {D、 Line 2 of class Target can be changed to private Integer i = 0;
考题
Which declarations will allow a class to be started as a standalone program?() A、public void main(String args[])B、public void static main(String args[])C、public static main(String[] argv)D、final public static void main(String [] array)E、public static void main(String args[])
考题
1. public class A { 2. void A() { 3. System.out.println(“Class A”); 4. } 5. public static void main(String[] args) { 6. new A(); 7. } 8. } What is the result?() A、 Class AB、 Compilation fails.C、 An exception is thrown at line 2.D、 An exception is thrown at line 6.E、 The code executes with no output.
考题
Public class test ( Public static void main (String args[]) ( System.out.printIn (6 ^ 3); ) ) What is the output?()
考题
现有: 1. class Propeller2 { 2. pulolic static void main (String[]args)//add code here? 3. { new Propeller2().topGo(); } 4. 5.void topGo() //add code here? 6. { middleGo(); } 7. 8.void middleGo() //add code here? 9. { go(); System.out.println ("late middle"); } void go() //add code here? 12. {throw new Exception(); } 13. } 为使代码通过编译,需要在哪一行加入声明throws Exception?() A、只在第11行B、在第8行和第11行C、在第5行、第8行和第11行D、在第2行、第5行、第8行和第11行
考题
下列有关main()方法的签名正确的是哪些?()A、 public static void main(String[] args){}B、 public static void main(){}C、 public static void main(String args[]){}D、 public void static main(String[] args){}
考题
现有: class TestApp{ public static void main (String[] args){ for (int i=0; iA、0123B、012456789C、0123456789D、012
考题
现有: class Top { static int x=l; public Top (inty) { x*=3; } } class Middle extends Top { public Middle() {x+=1; ) public static void main (String [] args) { Middle m = new Middle(); System. out .println (x); } } 结果为:() A、1B、2C、3D、编译失败
考题
现有: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main (string[] args) ( ((TestA)new TestB()).start(); ) } 运行结果是哪项?() A、 TeStAB、 TeStBC、编译失败D、运行时抛出异常
考题
下面哪些main方法可用于程序执行()A、public static void main(String[]args)B、public static void main(String[]x)C、public static void main(Stringargs[])D、public void main(String[]args)
考题
多选题Which declarations will allow a class to be started as a standalone program?()Apublic void main(String args[])Bpublic void static main(String args[])Cpublic static main(String[] argv)Dfinal public static void main(String [] array)Epublic static void main(String args[])
考题
多选题现有2 个文件: 1. package x; 2. public class X { 3. public static void doX() { System.out.print("doX "); } 4. } 和: 1. class Find { 2. public static void main(String [] args) { 3. //insert code here 4. } 5. } 哪两行分别插入到类Find 的第3 行将编译并产生输出“doX”? ()AdoX();BX.doX();Cx.X.doX();Dx.X myX = new x.X(); myX.doX();
考题
单选题Given classes defined in two different files: 1. package util; 2. public class BitUtils { 3. public static void process(byte[]) { /* more code here */ } 4. } 1. package app; 2. public class SomeApp { 3. public static void main(String[] args) { 4. byte[] bytes = new byte[256]; 5. // insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils?()A
process(bytes);B
BitUtils.process(bytes);C
util.BitUtils.process(bytes);D
SomeApp cannot use methods in BitUtils.E
import util.BitUtils.*; process(bytes);
考题
单选题Given classes defined in two different files: 1. package util; 2. public class BitUtils { 3. private static void process(byte[] b) { } 4. } 1. package app; 2. public class SomeApp { 3. public static void main(String[] args) { 4. byte[] bytes = new byte[256]; 5. // insert code here 6. } 7. } What is required at line 5 in class SomeApp to use the process method of BitUtils?()A
process(bytes);B
BitUtils.process(bytes);C
app.BitUtils.process(bytes);D
util.BitUtils.process(bytes);E
import util.BitUtils. *; process(bytes);F
SomeApp cannot use the process method in BitUtils.
考题
多选题下面哪些main方法可用于程序执行()Apublic static void main(String[]args)Bpublic static void main(String[]x)Cpublic static void main(Stringargs[])Dpublic void main(String[]args)
考题
单选题现有: class Passer f static final int X=5; public static void main (String [] args) { new Passer().go (x); System. out .print (x); } void go (int x) { System. out .print(x++); } 结果是什么?()A
55B
56C
65D
66
考题
单选题class Bird { static void talk() { System.out.print("chirp "); } } class Parrot extends Bird { static void talk() { System.out.print("hello "); } public static void main(String [] args) { Bird [] birds = {new Bird(), new Parrot()}; for( Bird b : birds) b.talk(); } } 结果为:()A
chirp chirpB
chirp helloC
hello helloD
编译失败
考题
单选题现有: class TestA { public void start() { System.out.println("TestA"); } } public class TestB extends TestA { public void start() { System.out.println("TestB"); } public static void main (string[] args) ( ((TestA)new TestB()).start(); ) } 运行结果是哪项?()A
TeStAB
TeStBC
编译失败D
运行时抛出异常
考题
单选题1. public class A { 2. void A() { 3. System.out.println(“Class A”); 4. } 5. public static void main(String[] args) { 6. new A(); 7. } 8. } What is the result?()A
Class AB
Compilation fails.C
An exception is thrown at line 2.D
An exception is thrown at line 6.E
The code executes with no output.
考题
单选题现有: class Banana2 f static int X=2; public static void main (String [] args) { int X=2; Banana2 b=new Banana2(); b.go(x); } static {x+=x; } void go (int x) { ++x; System. out.println (x); } 结果为:()A
7B
5C
3D
2
考题
多选题下列有关main()方法的签名正确的是哪些?()Apublic static void main(String[] args){}Bpublic static void main(){}Cpublic static void main(String args[]){}Dpublic void static main(String[] args){}
考题
单选题Given a class Repetition: 1. package utils; 2. 3. public class Repetition { 4. public static String twice(String s) { return s + s; } 5. } and given another class Demo: 1. // insert code here 2. 3. public class Demo { 4. public static void main(String[] args) { 5. System.out.println(twice(”pizza”)); 6. } 7. } Which code should be inserted at line 1 of Demo.java to compile and run Demo to print“pizzapizza”?()A
import utils.*;B
static import utils.*;C
import utils.Repetition.*;D
static import utils.Repetition. *;E
import utils.Repetition.twice();F
import static utils.Repetition.twice;G
static import utils.Repetition.twice;
考题
单选题现有: class TestApp{ public static void main (String[] args){ for (int i=0; i
A
0123B
012456789C
0123456789D
012
热门标签
最新试卷