Submitted by c-admin on Fri, 05/31/2019 - 05:29
Given the following source code, which of the lines that are commented out may be reinserted without introducing errors?
abstract class Bang{
//abstract void f(); //(0)
final void g(){}
//final void h(){} //(1)
protected static int i;
private int j;
}
final class BigBang extends Bang{
//BigBang(int n) { m = n; } //(2)
public static void main(String args[]){
Bang mc = new BigBang();
}
void h(){}
//void k(){ i++; } //(3)
//void l(){ j++; } //(4)
int m;
}
Select 1 option
A. final void h( ) { } //(1)
B. BigBang(int n) { m = n; } //(2)
C. void k( ) { i++ } //(3)
D. void l( ) { j++ } //(4)
E. abstract void f( ) ; //(0)
Submitted by c-admin on Fri, 05/31/2019 - 05:27
You are modeling a class hierarchy for living things. You have a class LivingThing which has an abstract method reproduce().
Now, you want to have 2 subclasses of LivingThing - Plant and Animal. Both do reproduce but the mechanisms are different. What would you do?
Select 1 option
A. Overload the reproduce method in Plant and Animal classes
B. Overload the reproduce method in LivingThing class.
C. Override the reproduce method in Plant and Animal classes
D. Either overload or override reproduce in Plant and Animal classes, it depends on the preference of the designer.
Submitted by c-admin on Wed, 05/29/2019 - 01:21
Consider the following variable declaration within the definition of an interface:
int i = 10;
Which of the following declarations defined in a non-abstract class, is equivalent to the above?
Select 1 option
A. public static int i = 10;
B. public final int i = 10;
C. public static final int i = 10;
D. public int i = 10;
E. final int i = 10;
Submitted by c-admin on Wed, 05/29/2019 - 01:19
What, if anything, is wrong with the following code?
abstract class TestClass{
transient int j;
synchronized int k;
final void TestClass(){}
static void f(){}
}
Select 1 option
A. The class TestClass cannot be declared abstract.
B. The variable j cannot be declared transient.
C. The variable k cannot be declared synchronized.
D. The constructor TestClass( ) cannot be declared final.
E. The method f( ) cannot be declared static.
F. This code has no errors.
Submitted by c-admin on Wed, 05/29/2019 - 01:09
Which of the following method definitions will prevent overriding of that method?
Select 4 options
A. public final void m1()
B. public static void m1()
C. public static final void m1()
D. public abstract void m1()
E. private void m1()
Pages