多项选择题

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; }


您可能感兴趣的试卷

你可能感兴趣的试题

1.单项选择题

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.

2.多项选择题

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;

4.单项选择题

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.

6.单项选择题

int i = 1,j = 10; 
do { 
if(i>j) { 
break; 
}
j--; 
} while (++i <5); 
System.out.println(“i =” +i+” and j = “+j);
What is the result?()

A. i = 6 and j = 5
B. i = 5 and j = 5
C. i = 6 and j = 4
D. i = 5 and j = 6
E. i = 6 and j = 6

7.多项选择题

class A { 
A() { } 
} 
class B extends A { 
} 
Which two statements are true?()

A. Class B’s constructor is public.
B. Class B’s constructor has no arguments.
C. Class B’s constructor includes a call to this().
D. Class B’s constructor includes a call to super().

10.多项选择题Which two cause a compiler error?() 

A. float[] = new float(3);
B. float f2[] = new float[];
C. float[] f1 = new float[3];
D. float f3[] = new float[3];
E. float f5[] = { 1.0f, 2.0f, 2.0f };
F. float f4[] = new float[] { 1.0f. 2.0f. 3.0f};