新闻资讯 > JAVA常见问题解答(七)
                                                                                      
     【发表日期】:2007年7月10日   【出处】:思达网校    【作者】:思达网校   【阅读】:

问题:Consider the classes defined below:

import java.io.*;

class Super

{

int methodOne( int a, long b ) throws IOException

{ // code that performs some calculations

   }

float methodTwo( char a, int b )

{ // code that performs other calculations

   }

}

public class Sub extends Super

{

}

Which of the following are legal method declarations to add to the

class Sub? Assume that

each method is the only one being added.

A.  public static void main( String args[] ){}

B. float methodTwo(){}

C. long methodOne( int c, long d ){}

D. int methodOne( int c, long d ) throws ArithmeticException{}

E. int methodOne( int c, long d ) throws FileNotFoundException{}

回答:答案应该是A,B,D,E。C中方法的返回类型应该和父类一致。对于一个方法来说,方法名/方法的参数类型/返回类型是决定方法的要素

咨讯评论
相关连接
 
网校预告
联系方式
 免费咨询电话:1169865432

 电 话:023-65472523

 课程咨询:edu@staredu.net
 联系人:李老师 王老师
文章搜索: