GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Quiz

Chapter 9 Review

bowtietigers 10 Fragen

Quiz starten

Fragen in diesem Quiz (10)

  1. 1Which of the following choices might serve as an interface for the other choices listed?
    1. APiano
    2. BDrum
    3. CGuitar
    4. DInstrument
    5. EFrenchHorn
  2. 2Which of the following code segments causes a compile-time error?
    1. AAirplane boeing707 = new Airplane();
    2. BFlier boeing707 = new Flier();
    3. CFlier boeing707 = new Airplane();
    4. DAirplane boeing707 = new Airplane();
      Flier airTraveler = boeing707;
    5. EAirplane boeing707 = new Airplane();
      Flier airTraveler;
      airTraveler = (Airplane) beoing707;
  3. 3Consider the following code segment.
    1 Airplane skyRider = new Airplane();
    2 Flier skyRider2 = skyRider;
    3 Athlete skyRider3 = (Athlete) skyRider2;
    4 Airplane skyRider4 = (Airplane) skyRider2;
    5 Flier skyRider5 = skyRider4;
    Which statement above will cause a run-time error and throw an exception?
    1. AStatement 1
    2. BStatement 2
    3. CStatement 3
    4. DStatement 4
    5. EStatement 5
  4. 4Airplane c = new Airplane();
    Flier f = new Airplane();
    Athlete a = new SkiJumper("Ann", "Smith");
    SkiJumper s = new SkiJumper("John", "Doe");

    Which of the following statements is not legal?
    1. Ac.fly();
    2. Bf.fly();
    3. Ca.train(3);
    4. Ds.train(3);
    5. Ea.fly();
  5. 5Airplane c = new Airplane();
    Flier f = new Airplane();
    Athlete a = new SkiJumper("Ann", "Smith");
    SkiJumper s = new SkiJumper("John", "Doe");

    Which of the following statements needs a cast?
    I. f = c;
    II. a = s;
    III. s = a;
    1. AI only
    2. BII only
    3. CIII only
    4. DI and II only
    5. EI and III only
  6. 6Suppose class C implements an interface I by implementing all of the methods of I and no further methods. Then which of the following must be true?
    1. AAll instance variables or C are public.
    2. BAll methods of C are abstract.
    3. CAll methods of C are public.
    4. DAll constants of C are public.
    5. EAll instance variables of C are private.
  7. 7Which of the following statements is true about casting?
    1. AYou must cast to convert from an interface type to a class type.
    2. BYou must cast to convert from a class type to an interface type.
    3. CYou cannot cast to convert an interface type to a class type.
    4. DYou cannot cast from a class type to an interface type.
    5. EBoth a and b above are true.
  8. 8Which of the following statements is true about dynamic binding?
    1. ADynamic binding occurs during compile time.
    2. BDynamic binding occurs when the appropriate overloaded method is selected.
    3. CDynamic binding is another name for early binding.
    4. DIn dynamic binding, the virtual machine selects the appropriate method.
    5. EDynamic binding occurs only when an interface declares public static final constants.
  9. 9Which of the following statements about interfaces is not true?
    1. AAn interface can specify constants that can be used by all classes that implement the interface.
    2. BAn interface can specify variables that can be used by all classes that implement the interface.
    3. CAn interface can specify methods that must be defined by all classes that implement the interface.
    4. DAn interface name cannot be instantiated.
    5. EThe interface contains declarations but not implementations.
  10. 10Suppose foo is an object of class C, and C implements the interface type I. Which of the following statements must be true?
    1. Afoo was constructed with the constructor of I.
    2. BC assigns values to all constants declared in the interface I.
    3. CC supplies an implementation for all methods of the interface I.
    4. Dfoo must be declared as
      I foo = new C();
    5. EAll methods of I are declared as private.

Informationen

Beschreibung
Review for chapter 9, which is on interfaces.
Sprache
English
Aufrufe
404
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck