1.
Which statement(s) are true? (Choose all that apply.)
Has-a relationships always rely on inheritance.
Has-a relationships always rely on instance variables.
Has-a relationships always require at least two class types.
Has-a relationships always rely on polymorphism.
Has-a relationships are always tightly coupled.
2.
Given:
class Clidders {
public final void flipper() { System.out.println("Clidder"); }
}
public class Clidlets extends Clidders {
public void flipper() {
System.out.println("Flip a Clidlet");
super.flipper();
}
public static void main(String [] args) {
new Clidlets().flipper();
}
}
What is the result?
Flip a Clidlet
Flip a Clidder
Flip a Clidder
Flip a Clidlet
Flip a Clidlet
Flip a Clidder
Compilation fails.
3.
Given:
public abstract interface Frobnicate { public void twiddle(String s) ; }
Which is a correct class? (Choose all that apply.)
public abstract class Frob implements Frobnicate {
public abstract void twiddle(String s){}
}
public abstract class Frob implements Frobnicate { }
public class Frob extends Frobnicate {
public void twiddle(Integer i) { }
}
public class Frob implements Frobnicate {
public void twiddle(Integer i) { }
}
public class Frob implements Frobnicate {
public void twiddle(String i) { }
public void twiddle(Integer s) { }
}
4.
Given:
class Top {
public Top(String s) { System.out.print("B"); }
}
public class Bottom2 extends Top {
public Bottom2(String s) { System.out.print("D"); }
public static void main(String [] args) {
new Bottom2("C");
System.out.println(" ");
}
}
What is the result?
BD
DB
BDC
DBC
Compilation fails.
5.
Select the two statements that best indicate a situation with low coupling. (Choose two.)
The attributes of the class are all private.
The class refers to a small number of other objects.
The object contains only a small number of variables.
The object is referred to using an anonymous variable, not directly.
The reference variable is declared for an interface type, not a class. The interface provides a small number of methods.
It is unlikely that changes made to one class will require any changes in another.
6.
Given:
class Clidder {
private final void flipper() { System.out.println ("Clidder"); }
}
public class Clidlet extends Clidder {
public final void flipper() { System.out.println("Clidlet"); }
public static void main(String [] args) {
new Clidlet().flipper();
}
}
What is the result?
Clidlet
Clidder
Clidder
Clidlet
Clidlet
Clidder
Compilation fails.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment