当前位置: 技术问答>java相关
请回答我的问题。谢谢
来源: 互联网 发布时间:2015-02-16
本文导语: 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 calculation...
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{}
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.
E.
答案正确?
B.
E.
答案正确?
|
C错是因为方法的签名相同,但返回值不同。
D是因为扔出的EXCEPTION不是IOCXCEPTION的子类或本身。
正确:
A.
B.
E.
D是因为扔出的EXCEPTION不是IOCXCEPTION的子类或本身。
正确:
A.
B.
E.