Given the code below:
interface MyInterface {
void doSomething ( ) ;
}
class MyClass implements MyInterface {
// xx
}
Choose the valid option that can be substituted in place of xx in the MyClass class .
public native void doSomething ( ) ;
void doSomething ( ) { /* valid code fragments */ }
private void doSomething ( ) { /* valid code fragments */ }
protected void doSomething ( ) { /* valid code fragments */ }
interface I1 {
void draw();
}
class C implements I1 {
xxxxxx
}
Which of the following when inserted at xxxxxx is a legal definition and
implementation ?
void draw() { }
public void draw() { }
protected void draw() { }
abstract void draw() { }
Given the following,
1. interface Count {
2.
short counter = 0;
3.
void countUp();
4. }
5. public class TestCount implements Count {
6.
7.
public static void main(String [] args) {
8.
TestCount t = new TestCount();
9.
[Link]();
10. }
11. public void countUp() {
12.
for (int x = 6; x>counter; x--, ++counter) {
13.
14.
[Link](" " + counter);
}
15. }
16. }
What is the result?
123
0123
1234
Compilation fails