首页/ 题库 / [单选题]

分析下列Java代码:&ensp的答案

分析下列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");  }   }    } 
编译运行后,输出结果是()。  
  

单选题
2021-12-30 05:44
A、"Hello"
B、"good-bye"
C、"Hello"后面是"good-bye"
D、代码不能编译
查看答案

正确答案
A

试题解析

感兴趣题目

现有: 
interface Data {public void load();} 
abstract class Info {public abstract void load();}     
下列类定义中正确使用Data和Info的是哪项?() 

int [] my_Array;   
my_Array = new int[5]; 
for(int count = 0; count <= 5; count++) 
System.out.println(my_Array[count]); 
以上Java代码运行的结果是()。 

在Java语言中,如果你有下面的类定义: 
Abstract class Shape{ Abstract void draw(); } 
class Square extendeds Shape{}
如果你试图编译上面的代码会发生()。 

在Java语言中,如果你有下面的类定义:  
abstract class Shape { 
abstract void draw();    }   
Class Square extends Shape {} 
如果你试图编译上面的代码会发生()。 

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  
结果为:()  

如下所示的这段CSS样式代码,定义的样式效果是()
a:link {color: #ff0000;}  
a:visited {color: #00ff00;}  
a:hover {color: #0000ff;}  
a:active {color: #000000;}  
其中#ff0000为红色,#00000为黑色,#0000ff为蓝色, #00ff00为绿色  

You are designing a top-level OU structure to meet the business and technical requirements. 
Which top-evel OU or OUs should you use? ()

import java.io.*; 
public class Forest implements Serializable { 
private Tree tree = new Tree(); 
public static void main(String [] args) { 
Forest f= new Forest(); 
try { 
FileOutputStream fs = new FileOutputStream(”Forest.ser”); 
ObjectOutputStream os = new ObjectOutputStream(fs); 
os.writeObject(f); os.close(); 
} catch (Exception ex) { ex.printStackTrace(); } 
} 
} 
class Tree { } 
What is the result?() 

为将数组myArray的长度由6改为10,现采取以下编码: 
int[] myArray = new int[6]; 
myArray = new int[10];  
代码执行后,以下叙述哪项是正确的?() 

为将数组myArray的长度由3改为6,现采取以下编码:     
int[]myArray=new int [3];     
myArray=new  int[6]; 
代码执行后,以下叙述哪项是正确的?() 
   

public class TestOne { 
public static void main (String[] args) throws Exception { 
Thread.sleep(3000); 
System.out.println(”sleep”); 
} 
} 
What is the result?() 

public class A extends Thread { 
A() { 
setDaemon(true); 
} 
public void run() { 
(new B()).start(); 
try { 
Thread.sleep(60000); 
} catch (InterruptedException x) {} 
System.out.println(“A done”); 
} 
class B extends Thread { 
public void run() { 
try { 
Thread.sleep(60000); 
} catch (InterruptedException x) {} 
System.out.println(“B done”); 
} 
} 
public static void main(String[] args) { 
(new A()).start(); 
} 
}  
What is the result?()  

相关题目

给出下列java源代码: 
//Point x 
Public class Interesting{} 
在源代码//point x处添加()能符合java语法 

阅读以下代码: 
public class Test{ 
public static void main(){ 
System.out.println(“x=”+x);   } } 
请问,代码运行的结果是?() 

public class Car { 
private int wheelCount; 
private String vin; 
public Car(String vin) { 
this.vin = vin; 
this.wheelCount = 4; 
} 
public String drive() { 
return “zoom-zoom”; 
} 
public String getInfo() { 
return “VIN: “+ vin + “wheels: “+ wheelCount; 
} 
} 
And: 
public class MeGo extends Car { 
public MeGo(String vin) { 
this.wheelCount = 3; 
} 
} 
What two must the programmer do to correct the compilation errors?()

1. class Pizza { 
2. java.util.ArrayList toppings; 
3. public final void addTopping(String topping) { 
4. toppings.add(topping);
5. } 
6. } 
7. public class PepperoniPizza extends Pizza { 
8. public void addTopping(String topping) { 
9. System.out.println(”Cannot add Toppings”); 
10. } 
11. public static void main(String[] args) { 
12. Pizza pizza = new PepperoniPizza(); 
13. pizza.addTopping(”Mushrooms”); 
14. } 
15. } 
What is the result?() 

 public class X { 
 public static void main (String[]args)   { 
 string s = new string (“Hello”); 
 modify(s); 
 System.out.printIn(s); 
 } 
 public static void modify (String s)  { 
 s += “world!”;  
   } 
 }     
What is the result?()  

分析下列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");  }   }    } 
编译运行后,输出结果是()。  
  

Assuming that the serializeBanana2() and the deserializeBanana2() methods will correctly use Java serialization and given: 
import java.io.*; 
class Food {Food() { System.out.print(”1”); } } 
class Fruit extends Food implements Serializable { 
Fruit() { System.out.print(”2”); } } 
public class Banana2 extends Fruit { int size = 42; 
public static void main(String [] args) { 
Banana2 b = new Banana2(); 
b.serializeBanana2(b); // assume correct serialization 
b = b.deserializeBanana2(b); // assume correct 
System.out.println(” restored “+ b.size + “ “); } 
// more Banana2 methods 
} 
What is the result?() 

import java.util.*; 
public class PQ { 
public static void main(String[] args) { 
PriorityQueue pq = new PriorityQueue(); 
pq.add(”carrot”);
pq.add(”apple”); 
pq.add(”banana”); 
System.out.println(pq.poll() +”:” + pq.peek());
} 
} 
What is the result?() 

What is wrong with the following code?()  
class MyException extends Exception {}  
public class Qb4ab {  
public void foo() {  try {  bar();  } finally {  baz();  
} catch (MyException e) {} 
}  
public void bar() throws MyException {  
throw new MyException(); 
}  
public void baz() throws RuntimeException {  
throw new RuntimeException(); 
 }  
}  

class Birds { 
public static void main(String [] args) { 
try { 
throw new Exception(); 
} catch (Exception e) {
try { 
throw new Exception(); 
} catch (Exception e2) { System.out.print("inner "); } 
System.out.print("middle ");
} 
System.out.print("outer "); 
} 
} 
结果为:()  

现有: 
class Birds { 
public static void main (String  []  args)  {  
try { 
throw new Exception () ;   
} catch (Exception e) {  
try { 
 throw new Exception () ; 
}  catch  (Exception e2)  {  System.out.print ("inner           "); } 
 System. out.print ( "middle" ) ;   
} 
System.out.print ("outer") ;   
}   
} 
结果是()

public class Test { 
public static void aMethod() throws Exception { 
try { 
throw new Exception();
} finally { 
System.out.println(“finally”); 
} 
} 
public static void main(String args[]) { 
try { 
aMethod(); 
} catch (Exception e) { 
System.out.println(“exception”); 
} 
System.out.println(“finished”); 
} 
} 
What is the result?()  

现有: 
void topGo()  {     
try  { 
middleGo(); 
}  catch  (Exception e)  {     
System.out.print("catch");     
}     
} 
void middleGo()  throws Exception  {    
go(); 
system.out.print("late middle");    
} 
void go()  throws ExceptiOn  {    
throw new Exception();    
}
如果调用 topGo () ,则结果为:() 

import java.io.IOException;  
public class ExceptionTest(  
public static void main (Stringargs) 
try (  
methodA();  
) catch (IOException e) (  
system.out.printIn(“Caught IOException”); 
) catch (Exception e) (  
system.out.printIn(“Caught Exception”);  
)  
)  
public void methodA () {  
throw new IOException (); 
}    
What is the result?()  

现有:  
class ThreadExcept implements Runnable {  
public void run() { throw new RuntimeException("exception "); } 
public static void main(String [] args) {  
new Thread(new ThreadExcept()).start();  
try {  
int x = Integer.parseInt(args[0]);  
Thread.sleep(x);  
System.out.print("main ");   
} catch (Exception e) { }     
}  
}  
和命令行: 
java ThreadExcept 1000   
哪一个是结果?() 

现有: 
class ThreadExcept implements Runnable  { 
public void run()  {  throw new RuntimeException("exception ");  } 
public static void main(Stri_ng  []  args)  { 
new  Thread (new  ThreadExcept()).start(); 
try  { 
int x=Integer.parselnt (args [0]); 
Thread. sleep (x); 
System.out.print("main"); 
} catch (Exception e)  {  } 
} 
} 
和命令行:  java ThreadExcept l000    
哪一个是结果?()    

在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要具备的环境都已经建立好。现在用完全正确的命令编译该文件,对于以下成熟正确的是()  

Which statements concerning the relationships between the following classes are true?()  
class Foo {  int num;  
Baz comp = new Baz();  
}  
class Bar {  boolean flag;  
}  
class Baz extends Foo {  
Bar thing = new Bar();  
double limit;  
}  

int index = 1;  
boolean test = new Boolean;  
boolean foo= test [index]; 
What is the result?()

String foo = “blue”; 
Boolean[]bar = new Boolean [1]; 
if (bar[0])  { 
foo = “green”; 
}  
What is the result? () 

广告位招租WX:84302438

免费的网站请分享给朋友吧