单项选择题

1. public class ReturnIt { 
2. return Type methodA(byte x, double y) { 
3. return (short)x / y * 2; 
4. } 
5. } 
What is the narrowest valid returnType for methodA in line2?()  

A. int
B. byte
C. long
D. short
E. float
F. double


您可能感兴趣的试卷

你可能感兴趣的试题

1.多项选择题In which two cases does the compiler supply a default constructor for class A?()  

A. class A{}
B. class A { public A(){} }
C. class A { public A(int x){} }
D. class Z {} class A extends Z { void A(){} }

5.单项选择题

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 A
B. 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.

10.多项选择题

public class X { 
public X aMethod() { return this;} 
} 
public class Y extends X { 
} 
Which two methods can be added to the definition of class Y?()

A. public void aMethod() {}
B. private void aMethod() {}
C. public void aMethod(String s) {}
D. private Y aMethod() { return null; }
E. public X aMethod() { return new Y(); }