logo

Crowdly

Browser

Add to Chrome

Dadas las siguientes clases, ¿qué ocurrirá al ejecutar el programa Prueba? El ma...

✅ The verified answer to this question is available below. Our community-reviewed solutions help you understand the material better.

Dadas las siguientes clases, ¿qué ocurrirá al ejecutar el programa Prueba? El marcado de incorrecta tiene penalización.

 

public class Vehiculo {

public void acelerar() {

System.out.println("Vehiculo acelerando");

}

}

public class Coche extends Vehiculo {

public void tocarClaxon() {

System.out.println("Coche tocando el claxon");

}

}

public class Patinete extends Vehiculo {

public void cargarBateria() {

System.out.println("Patinete cargando");

}

}

public class Prueba {

public static void main(String[] args) {

Vehiculo[] misVehiculos = new Vehiculo[2];

misVehiculos[0] = new Coche();

misVehiculos[1] = new Patinete();

for (int i=0;i < misVehiculos.length; i++) {

((Coche)misVehiculos[i]).tocarClaxon();

misVehiculos[i].acelerar();

}

}

}

 

0%
0%
0%
More questions like this

Want instant access to all verified answers on moodle.upm.es?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome