Which code fragments will succeed in initializing a two-dimensional array named tab with a size that will cause the expression tab[3][2] to access a valid element?()
CODE FRAGMENT a: int[][] tab = { { 0, 0, 0 }, { 0, 0, 0 } };
CODE FRAGMENT b: int tab[][] = new int[4][]; for (int i=0; i
CODE FRAGMENT c: int tab[][] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
CODE FRAGMENT d: int tab[3][2];
CODE FRAGMENT e: int[] tab[] = { {0, 0, 0}, {0, 0, 0}, {0, 0, 0}, {0, 0, 0} };
A.Code fragment a.
B.Code fragment b.
C.Code fragment c.
D.Code fragment d.
E.Code fragment e.
您可能感兴趣的试卷
你可能感兴趣的试题
A.Mark the method with the keyword public.
B.Mark the method with the keyword protected.
C.Mark the method with the keyword private.
D.Mark the method with the keyword package.
E.Do not mark the method with any accessibility modifiers.
A.default
B.NULL
C.String
D.throws
E.long
Which statements, when inserted at the indicated position in the following code, will cause a runtime exception when attempting to run the program?()
class A {}
class B extends A {}
class C extends A {}
public class Q3ae4 {
public static void main(String args[]) {
A x = new A();
B y = new B();
C z = new C();
// insert statement here
}
}
A.x = y;
B.z = x;
C.y = (B) x;
D.z = (C) y;
E.y = (A) y;
A.The charAt() method of the String class.
B.The toUpperCase() method of the String class.
C.The replace() method of the String class.
D.The reverse() method of the StringBuffer class.
E.The length() method of the StringBuffer class.
Which is the earliest line in the following code after which the object created on the line marked (0) will be a candidate for being garbage collected, assuming no compiler optimizations are done? ()
public class Q76a9 {
static String f() {
String a = "hello";
String b = "bye"; // (0)
String c = b + "!"; // (1)
String d = b; b = a; // (2)
d = a; // (3)
return c; // (4) }
public static void main(String args[]) {
String msg = f();
System.out.println(msg); // (5)
}
}
A.The line marked (1).
B.The line marked (2).
C.The line marked (3).
D.The line marked (4).
E.The line marked (5).
Which statements can be inserted at the indicated position in the following code to make the program write 1 on the standard output when run?()
public class Q4a39 {
int a = 1;
int b = 1;
int c = 1;
class Inner {
int a = 2; int get() {
int c = 3;
// insert statement here return c;
}
} Q4a39() {
Inner i = new Inner();
System.out.println(i.get()); }
public static void main(String args[]) {
new Q4a39();
}
}
A.c = b;
B.c = this.a;
C.c = this.b;
D.c = Q4a39.this.a;
E.c = c;
A.It affects which grid cell the components end up in.
B.It affects how the extra vertical space is distributed.
C.It affects the alignment of each component.
D.It affects whether the components completely fill their allotted display area vertically.
Which lines of code are valid declarations of a native method when occurring within the declaration of the following class?()
public class Qf575 {
// insert declaration of a native method here
}
A.native public void setTemperature(int kelvin);
B.private native void setTemperature(int kelvin);
C.protected int native getTemperature();
D.public abstract native void setTemperature(int kelvin);
E.native int setTemperature(int kelvin) {}
A.The particular event instance.
B.The source of the event.
C.The set of events that were triggered by the same action.
D.The type of event.
E.The type of component from which the event originated.
最新试题
Which code, inserted at line 4, guarantees that this program will output [1, 2]?()
What is the result?()
Which three changes should be made to adapt this class to be used safely by multiple threads?()
What is the result?()
Which statement is true?()
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()?()
Which two statements are true?()
Which three will compile and run without exception?()
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()