Which statements concerning the relationships between the following classes are true?()
class Foo { int num;
Baz comp = new Baz();
}
class Bar { boolean flag;
}
class Baz extends Foo {
Bar thing = new Bar();
double limit;
}
A.A Bar is a Baz.
B.A Foo has a Bar.
C.A Baz is a Foo.
D.A Foo is a Baz.
E.A Baz has a Bar.
您可能感兴趣的试卷
你可能感兴趣的试题
A.The operation col1.retainAll(col2) will not modify the col1 object.
B.The operation col1.removeAll(col2) will not modify the col2 object.
C.The operation col1.addAll(col2) will return a new collection object, containing elements from both col1 and col2.
D.The operation col1.containsAll(Col2) will not modify the col1 object.
Which statements concerning the following code are true?()
class a {
public a() {}
public a(int i) { this(); }
}
class b extends a {
public boolean b(String msg) { return false; }
}
class c extends b
{ private c() { super(); }
public c(String msg) { this(); }
public c(int i) {}
}
A.The code will fail to compile.
B.The constructor in a that takes an int as an argument will never be called as a result of constructing an object of class b or c.
C.Class c has three constructors.
D.Objects of class b cannot be constructed.
E.At most one of the constructors of each class is called as a result of constructing an object of class c.
Which expressions will evaluate to true if preceded by the following code?()
String a = "hello";
String b = new String(a);
String c = a;
char[] d = { ’h’, ’e’, ’l’, ’l’, ’o’ };
A.(a == "Hello")
B.(a == b)
C.(a == c)
D.a.equals(b)
E.a.equals(d)
What will be the result of attempting to run the following program?()
public class Qaa75 {
public static void main(String args[]) {
String[][][] arr = {
{ {}, null },
{ { "1", "2" }, { "1", null, "3" } },
{},
{ { "1", null } } };
System.out.println(arr.length + arr[1][2].length);
}
}
A.The program will terminate with an ArrayIndexOutOfBoundsException.
B.The program will terminate with a NullPointerException.
C.4 will be written to standard output.
D.6 will be written to standard output.
E.7 will be written to standard output.
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 two changes, taken together, would guarantee the output: 1, 2, 3, 4, 5?()
Which statement is true?()
Which statement is true?()
What is the result?()
What can be a result?()
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?()
Which statement is true?()
Given that t1 is a reference to a live thread, which is true?()
Which statement is true?()
Which statement is true about the set variable on line 12?()