单选题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 MyEx

题目
单选题
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();   }   }
A

Since the method foo() does not catch the exception generated by the method baz(), it must      declare the RuntimeException in its throws clause.

B

A try block cannot be followed by both a catch and a finally block.

C

An empty catch block is not allowed.

D

A catch block cannot follow a finally block.

E

A finally block must always follow one or more catch blocks.


相似考题
更多“What is wrong with the following code?()   class MyException”相关问题
  • 第1题:

    What will the following C code do?

    int *ptr;

    ptr =(int *)Ox67a9;

    *ptr = Oxaa55;


    正确答案:
     

  • 第2题:

    public class foo {   public static void main (Stringargs) {  String s;   system.out.printIn (“s=” + s);   }   }   What is the result?()

    • A、 The code compiles and “s=” is printed.
    • B、 The code compiles and “s=null” is printed.
    • C、 The code does not compile because string s is not initialized.
    • D、 The code does not compile because string s cannot be referenced.
    • E、 The code compiles, but a NullPointerException is thrown when toString is called.

    正确答案:C

  • 第3题:

    Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }  

    • A、The code will fail to compile.
    • B、The constructor in a that takes an int as an argument will never be called as a result of constructing an     object of class b or c.
    • C、Class c has three constructors.
    • D、Objects of class b cannot be constructed.
    • E、At most one of the constructors of each class is called as a result of constructing an object of class c.

    正确答案:B,C

  • 第4题:

    A developer used wsimport to generate the skeleton code for a Web service implementation. What is the purpose of the generated ObjectFactory class?() 

    • A、 The ObjectFactory class is the generated Service Endpoint Interface class
    • B、 The ObjectFactory class is the generated service provider class that is used by the JAX-WS client.
    • C、 The ObjectFactory class takes the targetNamespace value and creates the directory structure.
    • D、 The ObjectFactory class allows you to programatically construct new instances of the Java representation for XML content.

    正确答案:D

  • 第5题:

    You are developing a Windows Communication Foundation (WCF) service that is hosted by a Windows Forms Application.The ServiceHost instance is created in the Form Constructor.You need to ensure that the service is not blocked while the UI thread is busy. What should you do?()

    • A、Decorate the service implementation class with the following line of code [ServiceBehavior(UseSyncronizationContext = false)]
    • B、Decorate the service implementation class with the following line of code [ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Multiple)]
    • C、Call the Invoke method of the form and supply a delegate.
    • D、Call the BeginInvoke method of the form and supply a delegate.

    正确答案:A

  • 第6题:

    You work as an application developer at Certkiller .com. You have recently created a custom collection class named ShoppingList for a local supermarket. This custom class will include ShoppinItem objects that have the public properties listed below. * Name * AisleNumber * OnDiscount You are required to enable users of your class to iterate through the ShoppingList collection, and to list each product name and aisle number using the foreach statement.You need to achieve this by declaring the appropriate code.What code should you use?()

    • A、 public class ShoppingList : ICollection {// Class implementation }
    • B、 public class ShoppingList : IEnumerator, IEnumerable {// Class implementation }
    • C、 public class ShoppingList : Ilist {// Class implementation }
    • D、 public class ShoppingList : Enum {// Class implementation }

    正确答案:B

  • 第7题:

    单选题
    You develop a service application named PollingService that periodically calls long-running procedures.These procedures are called from the DoWork method.You use the following service application code:   When you attempt to start the service, you receive the following error message: Could not start the PollingService service on the local computer.Error 1053: The service did not respond to the start or control request in a timely fashion. You need to modify the service application code so that the service starts properly.What should you do?()
    A

    Move the loop code into the constructor of the service class from the OnStart method.

    B

    Drag a timer component onto the design surface of the service. Move the calls to the long-running procedure from the OnStart method into the Tick event procedure of the timer, set the Enabled property of the timer to True, and call the Start method of the timer in the OnStart method.

    C

    Add a class-level System.Timers.Timer variable to the service class code. Move the call to the DoWork method into the Elapsed event procedure of the timer, set the Enabled property of the timer to True, and call the Start method of the timer in the OnStart method.

    D

    Move the loop code from the OnStart method into the DoWork method.


    正确答案: A
    解析: 暂无解析

  • 第8题:

    单选题
    You are creating an ASP.NET Web site. The site has a master page named Custom.master. The code-behind file for Custom.master contains the following code segment.Partial Public Class Custom  Inherits System.Web.UI.MasterPagePublic Property Region As String    Protected Sub Page_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.LoadEnd SubEnd Class You create a new ASP.NET page and specify Custom.master as its master page.You add a Label control named lblRegion to the new page.  You need to display the value of the master pages Region property in lblRegion.What should you do? ()
    A

    Add the following code segment to the Page_Load method of the page code-behind file. Dim custom As Custom = Me.Parent  lblRegion.Text = custom.Region

    B

    Add the following code segment to the Page_Load method of the page code-behind file. Dim custom As Custom = Me.Master  lblRegion.Text = custom.Region

    C

    Add the following code segment to the Page_Load method of the Custom.Master.vb code-behind file. Dim lblRegion As Label = Page.FindControl(lblRegion) lblRegion.Text = Me.Region

    D

    Add the following code segment to the Page_Load method of the Custom.Master.vb code-behind file. Dim lblRegion As Label = Master.FindControl(lblRegion) lblRegion.Text = Me.Region


    正确答案: C
    解析: 暂无解析

  • 第9题:

    填空题
    Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.   class Base {   public void print( ) {   System.out.println("base");   }   }   class Extention extends Base {   public void print( ) {   System.out.println("extension");   // insert line of implementation here   }   }   public class Q294d {   public static void main(String args[]) {   Extention ext = new Extention( );   ext.print( );   }   }   Fill in a single line of implementation.()

    正确答案: super.print();
    解析: 暂无解析

  • 第10题:

    多选题
    You create a service application that monitors free space on a hard disk drive.  You must ensure that the service application runs in the background and monitors the free space every minute. What should you do?()
    A

    Add code to the default constructor of the Service class to monitor the free space on the hard disk drive.

    B

    Add code to the OnStart method of the Service class to monitor the free space on the hard disk drive.

    C

    Add an instance of the System.Windows.Forms.Timer class to the Service class and configure it to fire every minute.

    D

    Add an instance of the System.Timers.Timer class to the Service class and configure it to fire every minute.

    E

    Add code to the OnStart method of the Service class to start the timer.

    F

    Add code to the Elapsed event handler of the timer to monitor the free space on the hard disk drive.

    G

    Add code to the Tick event handler of the timer to monitor the free space on the hard disk drive.


    正确答案: A,G
    解析: 暂无解析

  • 第11题:

    单选题
    public class Foo {  public void main( String[] args ) {  System.out.println( “Hello” + args[0] );  }  }   What is the result if this code is executed with the command line?()
    A

     Hello

    B

     Hello Foo

    C

     Hello world

    D

     Compilation fails.

    E

     The code does not run.


    正确答案: E
    解析: 暂无解析

  • 第12题:

    多选题
    You work as an application developer at Certkiller .com. You have recently created an application domain for Certkiller .com. A few weeks later you are asked to retrieve information from this application domain, which is the current application domain. What can you do to achieve this objective?()
    A

    Use the following code: AppDomain appInfo = ApplicationDomain.Current;

    B

    Use the following code: AppDomain appInfo = AppDomain.CurrentDomain ();

    C

    Use the following code: AppDomain appInfo = Thread.GetDomain ();

    D

    Use the following code: AppDomain appInfo = MainThread.GetDomain ();


    正确答案: B,C
    解析: 暂无解析

  • 第13题:

    class One {  public One() { System.out.print(1); }  }  class Two extends One {  public Two() { System.out.print(2); }  }  class Three extends Two {  public Three() { System.out.print(3); }  }  public class Numbers{  public static void main( String[] argv) { new Three(); }  }  What is the result when this code is executed?() 

    • A、 1
    • B、 3
    • C、 123
    • D、 321
    • E、 The code rims with no output.

    正确答案:C

  • 第14题:

    public class Foo {  public void main( String[] args ) {  System.out.println( “Hello” + args[0] );  }  }   What is the result if this code is executed with the command line?()

    • A、 Hello
    • B、 Hello Foo
    • C、 Hello world
    • D、 Compilation fails.
    • E、 The code does not run.

    正确答案:E

  • 第15题:

    During system boot, rootvg fails to vary on, causing an LED code of 0552. What is the most likely cause for rootvg not varying on?()

    • A、Missing blv
    • B、Network problem
    • C、Wrong boot table
    • D、Corrupted file system

    正确答案:D

  • 第16题:

    public class Plant {  private String name;  public Plant(String name) { this.name = name; }  public String getName() { return name; }  }  public class Tree extends Plant {  public void growFruit() { }  public void dropLeaves() { }  }  Which is true?() 

    • A、 The code will compile without changes.
    • B、 The code will compile if public Tree() { Plant(); } is added to the Tree class.
    • C、 The code will compile if public Plant() { Tree(); } is added to the Plant class.
    • D、 The code will compile if public Plant() { this(”fern”); } is added to the Plant class.
    • E、 The code will compile if public Plant() { Plant(”fern”); } is added to the Plant class.

    正确答案:D

  • 第17题:

    You work as an application developer at Certkiller .com. Certkiller .com has instructed you to create a class named MetricFormula. This class will be used to compare MetricUnit and EnglishUnit objects.The MetricFormula is currently defined as follows (Line numbers are used for reference purposes only): 1. public class MetricFormula2. { 3. 4. } You need to ensure that the MetricFormula class can be used to compare the required objects. What should you do? ()

    • A、 Add the following code on line 1: : IComparable {
    • B、 Add the following code on line 1: : IComparer {
    • C、 Add the following code on line 3: public int Compare (object x, object y) {// implementation code }
    • D、 Add the following code on line 3: public int CompareTo (object obj) {// implementation code }

    正确答案:B,C

  • 第18题:

    You are developing a Windows Communication Foundation (WCF) service to replace an existing ASMX Web service.The WCF service contains the following code segment. (Line numbers are included for reference only.) 01 [ServiceContract( )] 02 03 public interface IEmployeeService 04 { 05 [OperationContract( )] 06 EmployeeInfo GetEmployeeInfo(int employeeID); 07 08 } 09 10 public class EmployeeService : IEmployeeService 11 { 12 13 public EmployeeInfo GetEmployeeInfo(int employeeID) 14 { 15 ... 16 } 17 } 18 19 20 public class EmployeeInfo 21 { 22 ... 23 public int EmployeeID { get; set; } 24 public string FirstName { get; set; } 25 public string LastName { get; set; } 26 27 }The existing Web service returns the EmployeelD as an attribute of the Employeelnfo element in the response XML.You need to ensure that applications can consume the service without code changes in the client. What should you do?()

    • A、Insert the following code at line 02. [DataContractFormat()] Insert the following code at line 22. [DataMember()]
    • B、Insert the following code at line 02. [XmlSerializerFormat()] Insert the following code at line 22. [XmlAtttibute()]
    • C、Insert the following code at line 09. [XmlSerializerFormat()] Insert the following code at line 22. [XmlAttribute()]
    • D、Insert the following code at line 19. [DataContractFormat()] Insert the following code at line 22. [DataMember()]

    正确答案:B

  • 第19题:

    多选题
    Which statements concerning the following code are true?()   class a {   public a() {}   public a(int i) { this(); }   }   class b extends a {   public boolean b(String msg) { return false; }   }   class c extends b  {  private c() { super(); }   public c(String msg) { this(); }   public c(int i) {}   }
    A

    The code will fail to compile.

    B

    The constructor in a that takes an int as an argument will never be called as a result of constructing an     object of class b or c.

    C

    Class c has three constructors.

    D

    Objects of class b cannot be constructed.

    E

    At most one of the constructors of each class is called as a result of constructing an object of class c.


    正确答案: E,D
    解析: 暂无解析

  • 第20题:

    单选题
    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();   }   }
    A

    Since the method foo() does not catch the exception generated by the method baz(), it must      declare the RuntimeException in its throws clause.

    B

    A try block cannot be followed by both a catch and a finally block.

    C

    An empty catch block is not allowed.

    D

    A catch block cannot follow a finally block.

    E

    A finally block must always follow one or more catch blocks.


    正确答案: B
    解析: 暂无解析

  • 第21题:

    单选题
    class One {  public One() { System.out.print(1); }  }  class Two extends One {  public Two() { System.out.print(2); }  }  class Three extends Two {  public Three() { System.out.print(3); }  }  public class Numbers{  public static void main( String[] argv) { new Three(); }  }  What is the result when this code is executed?()
    A

     1

    B

     3

    C

     123

    D

     321

    E

     The code rims with no output.


    正确答案: B
    解析: 暂无解析

  • 第22题:

    单选题
    You work as an application developer at Certkiller .com. You have recently created a custom collection class named ShoppingList for a local supermarket. This custom class will include ShoppinItem objects that have the public properties listed below. * Name * AisleNumber * OnDiscount You are required to enable users of your class to iterate through the ShoppingList collection, and to list each product name and aisle number using the foreach statement.You need to achieve this by declaring the appropriate code.What code should you use?()
    A

     public class ShoppingList : ICollection {// Class implementation }

    B

     public class ShoppingList : IEnumerator, IEnumerable {// Class implementation }

    C

     public class ShoppingList : Ilist {// Class implementation }

    D

     public class ShoppingList : Enum {// Class implementation }


    正确答案: D
    解析: 暂无解析

  • 第23题:

    单选题
    You work as an application developer at Certkiller .com. You are currently in the process of creating a class that stores data about Certkiller .com’s customers. Certkiller .com customers are assigned unique identifiers and various characteristics that may include aliases, shipping instructions, and sales comments. These characteristics can change in both size and data type. You start by defining the Customer class as shown below: public class Customer { private int custID; private ArrayList attributes; public int CustomerID { get {return custID;} } public Customer (int CustomerID) { this.custID = CustomerID; this.attributes = new ArrayList (); } public void AddAttribute (object att) {  attributes.Add (att); } } You have to create the FindAttribute method for locating attributes in Customer objects no matter what the data type is.You need to ensure that the FindAttributemethod returns the attribute if found,and you also need to ensure type-safety when returning the attribute.What should you do?()
    A

     Use the following code to declare the FindAttribute method: public T FindAttribute (T att) {//Find attribute and return the value }

    B

     Use the following code to declare the FindAttribute method: public object FindAttribute (object att) {//Find attribute and return the value }

    C

     Use the following code to declare the FindAttribute method: public T FindAttribute  (T att) {//Find attribute and return the value }

    D

     Use the following code to declare the FindAttribute method: public string FindAttribute (string att) {//Find attribute and return the value }


    正确答案: D
    解析: 暂无解析

  • 第24题:

    单选题
    Consider the following class:     class Test(int i) {     void test(int i) {  System.out.println(“I am an int.”); }    void test(String s) {   System.out.println(“I am a string.”);     }          public static void main(String args) {    Test t=new Test();     char ch=“y”;    t.test(ch);     }      }     Which of the statements below is true?()
    A

     Line 5 will not compile, because void methods cannot be overridden.

    B

     Line 12 will not compile, because there is no version of test() that rakes a charargument.

    C

     The code will compile but will throw an exception at line 12.

    D

     The code will compile and produce the following output: I am an int.

    E

     The code will compile and produce the following output: I am a String.


    正确答案: A
    解析: 在第12行,16位长的char型变量ch在编译时会自动转化为一个32位长的int型,并在运行时传给void test(int i)方法。