public class ArrayTest {
public static void main (Stringargs) {
float f1, f2;
f1 = new float [10];
f2 = f1;
System.out.printIn (“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 exception at runtime.
您可能感兴趣的试卷
你可能感兴趣的试题
ClassOne.java
package com.abc.pkg1;
public class ClassOne {
private char var = ‘a‘;
char getVar() {return var;}
}
ClassTest.java
package com.abc.pkg2;
import com.abc.pkg1.ClassOne;
public class ClassTest extends ClassOne {
public static void main(Stringargs) {
char a = new ClassOne().getVar();
char b = new ClassTest().getVar();
}
}
What is the result?()
A. Compilation will fail.
B. Compilation succeeds and no exceptions are thrown.
C. Compilation succeeds but an exception is thrown at line 5 in ClassTest.java.
D. Compilation succeeds but an exception is thrown at line 6 in ClassTest.java.
A. Public
B. Private
C. Protected
D. Transient
E. No access modifier is required
public class Mycircle {
public double radius;
public double diameter;
public void setRadius(double radius)
this.radius = radius;
this.diameter= radius * 2;
}
public double getRadius() {
return radius;
}
Which statement is true?()
A. The Mycircle class is fully encapsulated.
B. The diameter of a given MyCircle is guaranteed to be twice its radius.
C. Lines 6 and 7 should be in a synchronized block to ensure encapsulation.
D. The radius of a MyCircle object can be set without affecting its diameter.
A. An inner class may be declared as static.
B. An anonymous inner class can be declared as public.
C. An anonymous inner class can be declared as private.
D. An anonymous inner class can extend an abstract class.
E. An anonymous inner class can be declared as protected.
AnInterface is an interface.
AnAdapter0 is a non-abstract, non-final class with a zero argument constructor.
AnAdapter1 is a non-abstract, non-final class without a zero argument constructor, but with a constructor that takes one int argument.
Which two construct an anonymous inner class? ()
A. AnAdapter1 aa=new AnAdapter1(){}
B.AnAdapter0 aa=new AnAdapter0(){}
C. AnAdapter0 aa=new AnAdapter0(5){}
D. AnAdapter1 aa=new AnAdapter1(5){}
E.AnInterface a1=new AnInterface(5){}
class A {
public byte getNumber () {
return 1;
}
}
class B extends A {
public short getNumber() {
return 2;
}
public static void main (String args) {
B b = new B ();
System.out.printIn(b.getNumber())
}
}
What is the result?()
A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 14 causes compilation to fail.
E. Compilation succeeds but an exception is thrown at line 14.
A. An anonymous class can be declared as static.
B. A static inner class cannot be a static member of the outer class.
C. A static inner class does not require an instance of the enclosing class.
D. Instance members of a static inner class can be referenced using the class name of the static inner class.
class BaseClass{
private float x= 1.0f;
protected void setVar (float f) {x = f;}
}
class SubClass exyends BaseClass {
private float x = 2.0f;
//insert code here 8. }
Which two are valid examples of method overriding?()
A. Void setVar(float f) {x = f;}
B. Public void setVar(int f) {x = f;}
C. Public void setVar(float f) {x = f;}
D. Public double setVar(float f) {x = f;}
E. Public final void setVar(float f) {x = f;}
F. Protected float setVar() {x=3.0f; return 3.0f; }
class A {
public int getNumber(int a) {
return a + 1;
}
}
class B extends A {
public int getNumber (int a) {
return a + 2
}
public static void main (String args) {
A a = new B();
System.out.printIn(a.getNumber(0));
}
}
What is the result? ()
A. Compilation succeeds and 1 is printed.
B. Compilation succeeds and 2 is printed.
C. An error at line 8 causes compilation to fail.
D. An error at line 13 causes compilation to fail.
E. An error at line 14 causes compilation to fail.
import java.awt.*;
public class Test extends Frame {
public Test() {
add(new Label(“Hello”) );
add(new TextField(“Hello”) );
add(new Button(“Hello”) );
pack();
show();
}
public static void main(String args) {
new Test ();
}
}
What is the result? ()
A. The code will not compile.
B. A Window will appear containing only a Button.
C. An IllegalArgumentException is thrown at line 6.
D. A Window button will appear but will not contain the Label, TextField, or Button.
E. A Window will appear containing a Label at the top, a TextField below the Label, and a Button below the TextField.
F. A Window will appear containing a Label on the left, a TextField to the right of the Label, and a button to the right of the TextField.
最新试题
Which statement is true?()
What is the result?()
What is the output if the main() method is run?()
What is the result?()
Which statement is true?()
Which two statements are true?()
Which two are possible results?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
What is the result?()
What is the result?()