<a
href="http://www.yesadvertising.com">affiliate marketing</a>Which one of these is a valid method declaration?
Select the one correct answer.
void method1 { /* ... */ }
void method2() { /* ... */ }
void method3(void) { /* ... */ }
method4() { /* ... */ }
method5(void) { /* ... */ }
Given a class named Book, which one of these is a valid constructor declaration for the class?
Select the one correct answer.
Book(Book b) {}
Book Book() {}
private final Book() {}
void Book() {}
public static void Book(String[] args) {}
abstract Book() {}
What will be the result of attempting to compile the following program?
public class MyClass {
long var;
public void MyClass(long param) { var = param; } // (1)
public static void main(String[] args) {
MyClass a, b;
a = new MyClass(); // (2)
b = new MyClass(5); // (3)
}
}
Select the one correct answer.
Your Ad Here
A compilation error will occur at (1), since constructors cannot specify a return value.
A compilation error will occur at (2), since the class does not have a default constructor.
A compilation error will occur at (3), since the class does not have a constructor which takes one argument
of type int.
The program will compile correctly.
Which one of the following class definitions is a valid definition of a class that cannot be instantiated?
Select the one correct answer.
Your Ad Here
class Ghost {
abstract void haunt();
}
abstract class Ghost {
void haunt();
}
abstract class Ghost {
void haunt() {};
}
abstract Ghost {
abstract void haunt();
}
static class Ghost {
abstract haunt();
}
Which one of the following class definitions is a valid definition of a class that cannot be extended?
Select the one correct answer.
class Link { }
abstract class Link { }
native class Link { }
static class Link { }
final class Link { }
private class Link { }
abstract final class Link { }
" />
<a
href="http://www.yesadvertising.com">affiliate marketing</a>