Given the following code, write a line of code that, when inserted at the indicated location, will make the overriding method in Extension invoke the overridden method in class Base on the current object.
class Base {
public void print() {
System.out.println("base");
}
}
class Extention extends Base {
public void print() {
System.out.println("extension");
// insert line of implementation here
}
}
public class Q294d {
public static void main(String args[]) {
Extention ext = new Extention();
ext.print();
}
}
Fill in a single line of implementation.()
您可能感兴趣的试卷
你可能感兴趣的试题
A.FileOutputStream has no constructors matching the given arguments.
B.An IOExeception will be thrown if a file named "data" already exists.
C.An IOExeception will be thrown if a file named "data" does not already exist.
D.If a file named "data" exists, its contents will be reset and overwritten.
E.If a file named "data" exists, output will be appended to its current contents.
A.At most one listener of each type can be registered with a component.
B.Mouse motion listeners can be registered on a List instance.
C.There exists a class named ContainerEvent in package java.awt.event.
D.There exists a class named MouseMotionEvent in package java.awt.event.
E.There exists a class named ActionAdapter in package java.awt.event.
What will be the appearance of an applet with the following init() method?
public void init() {
add(new Button("hello")); }
A.Nothing appears in the applet.
B.A button will cover the whole area of the applet.
C.A button will appear in the top left corner of the applet.
D.A button will appear, centered in the top region of the applet.
E.A button will appear in the center of the applet.
A.private
B.final
C.static
D.int
E.abstract
A.All switch statements must have a default label.
B.There must be exactly one label for each code segment in a switch statement.
C.The keyword continue can never occur within the body of a switch statement.
D.No case label may follow a default label within a single switch statement.
E.A character literal can be used as a value for a case label.
What will be the result of attempting to compile and run the following code?()
public class Q6b0c {
public static void main(String args[]) {
int i = 4;
float f = 4.3;
double d = 1.8;
int c = 0;
if (i == f) c++;
if (((int) (f + d)) == ((int) f + (int) d))
c += 2;
System.out.println(c);
}
}
A.The code will fail to compile.
B.0 will be written to the standard output.
C.1 will be written to the standard output.
D.2 will be written to the standard output.
E.3 will be written to the standard output.
A.Member variables of the outer instance are always accessible to inner instances, regardless of their accessibility modifiers.
B.Member variables of the outer instance can never be referred to using only the variable name within the inner instance.
C.More than one inner instance can be associated with the same outer instance.
D.All variables from the outer instance that should be accessible in the inner instance must be declared final.
E.A class that is declared final cannot have any inner classes.
A.Instances of class Thread have a method called notify().
B.A call to the method notify() will wake the thread that currently owns the monitor of the object.
C.The method notify() is synchronized.
D.The method notifyAll() is defined in class Thread.
E.When there is more than one thread waiting to obtain the monitor of an object, there is no way to be sure which thread will be notified by the notify() method.
Given the following interface definition, which definitions are valid?()
interface I {
void setValue(int val);
int getValue();
}
DEFINITION a:
(a) class a extends I { int value;
void setValue(int val) { value = val;
}
int getValue() {
return value;
}
}
DEFINITION b:
(b) interface b extends I {
void increment();
}
DEFINITION c:
(c) abstract class c implements I {
int getValue() {
return 0;
} abstract void increment();
}
DEFINITION d:
(d) interface d implements I { void increment(); }
DEFINITION e:
(e) class e implements I { int value;
public void setValue(int val) { value = val; } }
A.Definition a.
B.Definition b.
C.Definition c.
D.Definition d.
E.Definition e.
What will be the result of attempting to compile and run the following program?()
public class Q28fd {
public static void main(String args[]) {
int counter = 0;
l1:
for (int i=10; i<0; i--) {
l2: int j = 0;
while (j < 10) {
if (j > i) break l2;
if (i == j) {
counter++;
continue l1;
}
}
counter--;
}
System.out.println(counter);
}
}
A.The program will fail to compile.
B.The program will not terminate normally.
C.The program will write 10 to the standard output.
D.The program will write 0 to the standard output.
E.The program will write 9 to the standard output.
最新试题
What is the result?()
What is the result?()
Which statement is 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?()
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 statements are true?()
What is the result?()
Given a class whose instances, when found in a collection of objects, are sorted by using the compareTo() method, which two statements are true?()