- Given:Which is a correct class? (Choose all that apply.)public abstract interface Frobnicate {public void twiddle(String s);}
- Given:What is the result?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(" ");}}
- Given:What is the result: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();}}
- Use the fragments below, complete the following code so it compiles. Note, you may not have to fill all of the slots.
Code:Fragments: Use the following fragments zero or more times:class AgedP {__________ __________ __________ __________ __________public AgedP(int x) {__________ __________ __________ __________ __________}}public class Kinder extends AgedP {__________ __________ __________ _________ ________ __________public Kinder(int x) {__________ __________ __________ __________ __________ ();}}AgedP super this ( ) { } ; - Given the following,Which, inserted at line 9, will compile? (Choose all that apply.)1. class X { void do1() { } }2. class Y extends X { void do2() { } }3.4. class Chrome {5. public static void main(String[] args) {6. X x1 = new X();7. X x2 = new Y();8. Y y1 = new Y();9. // insert code here10. } }
- Given:What is the result? (Choose all that apply.)3. class Dog {4. public void bark() { System.out.print("woof "); }5. }6. class Hound extends Dog {7. public void sniff() { System.out.print("sniff "); }8. public void bark() { System.out.print("howl "); }9. }10. public class DogShow {11. public static void main(String[] args) { new DogShow().go(); }12. void go() {13. new Hound().bark();14. ((Dog) new Hound()).bark();15. ((Dog) new Hound()).sniff();16. }17. }
- Given:What is the result? (Choose all that apply.)3. public class Redwood extends Tree {4. public static void main(String[] args) {5. new Redwood().go();6. }7. void go() {8. go2(new Tree(), new Redwood());9. go2((Redwood) new Tree(), new Redwood());10. }11. void go2(Tree t1, Redwood r1) {12. Redwood r2 = (Redwood) t1;13. Tree t2 = (Tree) r1;14. }15. }16. class Tree {}
- Given:What is the result?3. public class Tenor extends Singer {4. public static String sing() { return "fa"; }5. public static void main(String[] args) {6. Tenor t = new Tenor();7. Singer s = new Tenor();8. System.out.println(t.sing() + " " + s.sing());9. }10. }11. class Singer { public static String sing() { return "la"; } }
- Given:What is the result?3. class Alpha {4. static String s = " ";5. protected Alpha() { s += "alpha "; }6. }7. class SubAlpha extends Alpha {8. private SubAlpha() { s += "sub "; }9. }10. public class SubSubAlpha extends Alpha {11. private SubSubAlpha() { s += "subsub "; }12. public static void main(String[] args) {13. new SubSubAlpha();14. System.out.println(s);15. }16. }
- Given:What is the result?3. class Building {4. Building() { System.out.print("b "); }5. Building(String name) {6. this(); System.out.print("bn " + name);7. }8. }9. public class House extends Building {10. House() { System.out.print("h "); }11. House(String name) {12. this(); System.out.print("hn " + name);13. }14. public static void main(String[] args) { new House("x "); }15. }
- Given:What is the result?3. class Mammal {4. String name = "furry ";5. String makeNoise() { return "generic noise"; }6. }7. class Zebra extends Mammal {8. String name = "stripes ";9. String makeNoise() { return "bray"; }10. }11. public class ZooKeeper {12. public static void main(String[] args) { new ZooKeeper().go(); }13. void go() {14. Mammal m = new Zebra();15. System.out.println(m.name + m.makeNoise());16. }17. }
- You're designing a new online board game in which Floozels are a type of Jammers, Jammers can have Quizels, Quizels are a type of Klakker, and Floozels can have several Floozets. Which of the following fragments represent this design? (Choose all that apply.)
- Given:What is the result?3. class A { }4. class B extends A { }5. public class ComingThru {6. static String s = "-";7. public static void main(String[] args) {8. A[] aa = new A[2];9. B[] ba = new B[2];10. sifter(aa);11. sifter(ba);12. sifter(7);13. System.out.println(s);14. }15. static void sifter(A[]... a2) { s += "1"; }16. static void sifter(B[]... b1) { s += "2"; }17. static void sifter(B[] b1) { s += "3"; }18. static void sifter(Object o) { s += "4"; }19. }
Comments
Post a Comment