Fichas
Object Orientated Programming - Java
Fichas del conjunto (5)
- 1What does the following refer to? "Cohesion is the OO principle most closely associated with allowing a single object to be seen as having many types"Polymorthism
- 2What does the following refer to? "Cohesion is the OO principle most closely associated with hiding implementation details"Encapsulation
- 3What will the output be... class Car { String noise = "vroom"; String horn() { return "beep" } } class Ferrari extends car { String noise = "VROOM!"; String horm() { return "beeeeep!" }} public static void main { Car c = new Ferrari(); println(c.noise; c.horn());"vroom beeeeep!"
Polymorphism is only for instance methods. - 4Given... "public abstract interface X { public void y(String s); }" ...can it be overloaded?Yes, but you must keep the additional 'y' method, e.g...
"public abstract interface X {
public void y(String s);
public void y(Integer i) }" - 5What is the result from... class Cheese { public final void smell() { .println "cheesy" }} class Stilton extends Cheese{ public final void smell() { .println "stiltony" } /*main code*/ { new Stilton.smell() }"cheesy"
because the class is public, however if its private it would have been "stiltony"
Información
- Descripción
- Fichas sobre Object Orientated Programming - Java, creado por b3014292 el 04/07/2016.
- Creado por
- b3014292
- Visitas
- 2
- Valoración