READ Free Dumps For Oracle- 1z0-804
Question ID 21433 | Given:
interface Car {
public void start();
}
class BasicCar implements Car {
public void start() {}
}
public class SuperCar {
Car c = new BasicCar ();
public void start() {
c.start();
}
}
Which three are true?
|
Option A | BasicCar uses composition.
|
Option B | SuperCar uses composition.
|
Option C | BasicCar is-a Car.
|
Option D | SuperCar is-a Car.
|
Option E | SuperCar takes advantage of polymorphism
|
Option F | BasicCar has-a Car
|
Correct Answer | B,C,E |
Explanation Explanation: B: The relationship modeled by composition is often referred to as the "has-a" relationship. Here SuperCar hasa Car. C:The relationship modeled by inheritance is often referred to as the "is-a" relationship. Modeling an is-a relationship is called inheritance because the subclass inherits the interface and, by default, the implementation of the superclass. Inheritance of interface guarantees that a subclass can accept all the same messages as its superclass. A subclass object can, in fact, be used anywhere a superclass object is called for. E:The polymorphic method call allows one type to express its distinction from another, similar type, as long as they're both derived from the same base type. This distinction is expressed through differences in behavior of the methods that you can call through the base class.
Question ID 21434 | Given:
import java.util.ArrayList;
import java.util.List;
interface Glommer { }
interface Plinkable { }
public class Flimmer implements Plinkable {
List<Tagget> t = new ArrayList<Tagget>();
}
class Flommer extends Flimmer { }
class Tagget {
void doStuff() {
String s = "yo";
}
}
Which three statements concerning the OO concepts "is-a" and "has-a" are true?
|
Option A | Flimmer is-a Plinkable
|
Option B | Flommer has-a Tagget
|
Option C | Flommer is-a Glommer
|
Option D | Tagget has-a String
|
Option E | Flommer is-a Plinkable
|
Option F | Flimmer is-a Flommer
|
Correct Answer | A,B,E |
Explanation Explanation: A: Flimmer implements Plinkable. Flimmer is-a plinkable. D:The relationship modeled by composition is often referred to as the "has-a" relationship. HereTaggethasaString. F: Flommer extends Flimmer So there is an "is-a relationship between Flommer and Flimmer . Note: Thehas-a relationship has anencapsulation feature (like private or protected modifier used before each member field or method).