Given the following class, which statements can be inserted at position 1 without causing the code to fail compilation?()
public class Q6db8 {
int a;
int b = 0;
static int c;
public void m() {
int d;
int e = 0;
// Position 1
}
}
A.a++;
B.b++;
C.c++;
D.d++;
E.e++;
您可能感兴趣的试卷
你可能感兴趣的试题
If this source code is contained in a file called SmallProg.java, what command should be used to compile it using the JDK?()
public class SmallProg {
public static void main(String args[])
{ System.out.println("Good luck!"); } }
A.java SmallProg
B.avac SmallProg
C.javac SmallProg.java
D.java SmallProg main
A.They pass messages by modifying each other’s member variables
B.They pass messages by modifying the static member variables of each other’s classes
C.They pass messages by calling each other’s instance member methods
D.They pass messages by calling static member methods of each other’s classes.
Given that Thing is a class, how many objects and reference variables are created by the following code?()
Thing item, stuff;
item = new Thing();
Thing entity = new Thing();
A.One object is created
B.Two objects are created
C.Three objects are created
D.One reference variable is created
E.Two reference variables are created
F.Three reference variables are created.
Which line contains a constructor in this class definition?()
public class Counter { // (1)
int current, step;
public Counter(int startValue, int stepValue) { // (2)
set(startValue);
setStepValue(stepValue); }
public int get() { return current; } // (3)
public void set(int value) { current = value; } // (4)
public void setStepValue(int stepValue) { step = stepValue; } // (5) }
A.Code marked with (1) is a constructor
B.Code marked with (2) is a constructor
C.Code marked with (3) is a constructor
D.Code marked with (4) is a constructor
E.Code marked with (5) is a Constructor
A.is also called a static member
B.is always a variable
C.is never a method
D.belongs to a single instance, not to the class as a whole
E.always represents an operation
A.what classes are instantiated from.
B.an instance of a class.
C.a blueprint for creating concrete realization of abstractions.
D.a reference to an attribute.
E.a variable.
A.an implementation of an abstraction.
B.an attribute defining the property of a particular abstraction.
C.a category of objects.
D.an operation defining the behavior for a particular abstraction.
E.a blueprint for making operations.
1. public class X {
2. public object m () {
3. object o = new float (3.14F);
4. object [] oa = new object [1];
5. oa[0]= o;
6. o = null;
7. oa[0] = null;
10. return o;
9. }
10. }
When is the float object created in line 3, eligible for garbage collection?()
A. Just after line 5.
B. Just after line 6.
C. Just after line 7.
D. Just after line 8(that is, as the method returns).
public class MethodOver {
private int x, y;
private float z;
public void setVar(int a, int b, float c){
x = a;
y = b;
z = c;
}
}
Which two overload the setVar method?()
A. void setVar (int a, int b, float c){ x = a; y = b; z = c; }
B. public void setVar(int a, float c, int b) { setVar(a, b, c); }
C. public void setVar(int a, float c, int b) { this(a, b, c); }
D. public void setVar(int a, float b){ x = a; z = b; }
E. public void setVar(int ax, int by, float cz) { x = ax; y = by; z = cz; }
1. class A {
2. public String toString () {
3. return “4”;
4. }
5. }
6. class B extends A {
7. public String toString () {
8. return super.toString() + “3”;
9. }
10. }
11. public class Test {
12. public static void main(String[]args) {
13. System.out.printIn(new B());
14. }
15. }
What is the result?()
A. Compilation succeeds and 4 is printed.
B. Compilation succeeds and 43 is printed.
C. An error on line 9 causes compilation to fail.
D. An error on line 14 causes compilation to fail.
E. Compilation succeeds but an exception is thrown at line 9.
最新试题
Which statement is true?()
Which three will compile and run without exception?()
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 two of statements are true?()
A programmer is developing a class Key, that will be used as a key in a standard java.util.HashMap. Which two methods should be overridden to assure that Key works correctly as a key?()
What is the result?()
What can be a result?()
Which two statements are true?()
Which two are possible results?()
A programmer iterates over the TreeSet and prints the name of each Drink object. What is the result?()