Quiz
Chapter 9 Review
Erstelle ein kostenloses Konto, um dieses Quiz zu beenden
Speichere deinen Fortschritt und sieh dir dein Endergebnis an.
oder mit deiner E-Mail registrieren
Schon ein Konto? Anmelden
Fragen in diesem Quiz (10)
1Which of the following choices might serve as an interface for the other choices listed?
- APiano
- BDrum
- CGuitar
- DInstrument
- EFrenchHorn
2Which of the following code segments causes a compile-time error?
- AAirplane boeing707 = new Airplane();
- BFlier boeing707 = new Flier();
- CFlier boeing707 = new Airplane();
- DAirplane boeing707 = new Airplane();
Flier airTraveler = boeing707; - EAirplane boeing707 = new Airplane();
Flier airTraveler;
airTraveler = (Airplane) beoing707;
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?- AStatement 1
- BStatement 2
- CStatement 3
- DStatement 4
- EStatement 5
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?- Ac.fly();
- Bf.fly();
- Ca.train(3);
- Ds.train(3);
- Ea.fly();
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;- AI only
- BII only
- CIII only
- DI and II only
- EI and III only
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?
- AAll instance variables or C are public.
- BAll methods of C are abstract.
- CAll methods of C are public.
- DAll constants of C are public.
- EAll instance variables of C are private.
7Which of the following statements is true about casting?
- AYou must cast to convert from an interface type to a class type.
- BYou must cast to convert from a class type to an interface type.
- CYou cannot cast to convert an interface type to a class type.
- DYou cannot cast from a class type to an interface type.
- EBoth a and b above are true.
8Which of the following statements is true about dynamic binding?
- ADynamic binding occurs during compile time.
- BDynamic binding occurs when the appropriate overloaded method is selected.
- CDynamic binding is another name for early binding.
- DIn dynamic binding, the virtual machine selects the appropriate method.
- EDynamic binding occurs only when an interface declares public static final constants.
9Which of the following statements about interfaces is not true?
- AAn interface can specify constants that can be used by all classes that implement the interface.
- BAn interface can specify variables that can be used by all classes that implement the interface.
- CAn interface can specify methods that must be defined by all classes that implement the interface.
- DAn interface name cannot be instantiated.
- EThe interface contains declarations but not implementations.
10Suppose foo is an object of class C, and C implements the interface type I. Which of the following statements must be true?
- Afoo was constructed with the constructor of I.
- BC assigns values to all constants declared in the interface I.
- CC supplies an implementation for all methods of the interface I.
- Dfoo must be declared as
I foo = new C(); - EAll methods of I are declared as private.
Informationen
- Beschreibung
- Review for chapter 9, which is on interfaces.
- Autor
- bowtietigers
- Sprache
- English
- Aufrufe
- 404
- Schlagwörter
- Bewertung
- Noch keine Bewertungen Bewerte dieses Quiz