单项选择题

1. class Super { 
2. public float getNum() { return 3.0f; } 
3. } 
4.  
5. public class Sub extends Super { 
6.  
7. } 
Which method, placed at line6, causes compilation to fail?()  

A. public void getNum(){}
B. public void getNum(double d){}
C. public float getNum() { return 4.0f; }
D. public double getNum(float d) { return 4.0d; }


您可能感兴趣的试卷

你可能感兴趣的试题

2.单项选择题

public class ArrayTest { 
public static void main(String[] args) { 
float fl[], f2[]; 
fl = new float[10]; 
f2 = f1; 
System.out.println(“f2[0]= “ + f2[0]); 
} 
} 
What is the result?()  

A. It prints f2[0] = 0.0.
B. It prints f2[0] = NaN.
C. An error at line 5 causes compile to fail.
D. An error at line 6 causes compile to fail.
E. An error at line 6 causes an expectation at runtime.

5.多项选择题

class A { 
protected int method1(int a, int b) { return 0; } 
} 
Which two are valid in a class that extends class A?() 

A. public int method1(int a, int b) { return 0; }
B. private int method1(int a, int b) { return 0; }
C. private int method1(int a, long b) { return 0; }
D. public short method1(int a, int b) { return 0: }
E. static protected int method1(int a, int b) { return 0; }

6.单项选择题

package test1; 
public class Test1 { 
static int x = 42; 
} 
package test2; 
public class Test2 extends test1.Test1 { 
public static void main(String[] args) {
System.out.println(“x = “ + x); 
} 
} 
What is the result?() 

A. x = 0
B. x = 42
C. Compilation fails because of an error in line 2 of class Test2.
D. Compilation fails because of an error in line 3 of class Test1.
E. Compilation fails because of an error in line 4 of class Test2.

7.多项选择题

public interface Foo { 
int k = 4; 3. } 
Which three are equivalent to line 2?()

A. final int k = 4;
B. public int k = 4;
C. static int k = 4;
D. abstract int k = 4;
E. volatile int k = 4;
F. protected int k = 4;

9.单项选择题

int x = 3; 
int y = 1; 
if (x = y) { 
System.out.println(“x = “ + x); 
} 
What is the result? ()

A.x=1
B.x=3
C.Compilation fails.
D.The code runs with no output. 
E.An exception is thrown at runtime.

最新试题

Which three changes should be made to adapt this class to be used safely by multiple threads?()

题型:多项选择题

What is the appropriate definition of the hashCode method in class Person?()

题型:单项选择题

Given that Triangle implements Runnable, and:Which two statements, inserted independently at both lines 35 and 41, tend to allow both threads to temporarily pause and allow the other thread to execute?()

题型:多项选择题

Given:  foo and bar are public references available to many other threads, foo refers to a Thread and bar is an Object. The thread foo is currently executing bar.wait().  From another thread, what provides the most reliable way to ensure that foo will stop executing wait()?()

题型:单项选择题

What is the output if the main()  method is run?()

题型:单项选择题

A programmer iterates over the TreeSet and prints the name of each Drink object.  What is the result?()

题型:单项选择题

What is the result?()

题型:单项选择题

What is the result?()

题型:单项选择题

Which statement is true?()

题型:单项选择题

Which two can be results?()

题型:多项选择题