Pubblicato il di adminTest Java Online 1. Qual è l’istruzione di controllo che permette di scegliere tra due alternative? A. for B. if C. whileABCQuestion 1 of 10 2. Quale sarà l'output for(int i = 0; i < 3; i++) { switch(i) { case 0: break; case 1: System.out.print("one "); case 2: System.out.print("two "); case 3: System.out.print("three "); } } System.out.println("done")doneone two doneone two three doneone two three two three doneQuestion 2 of 10 3. Qual è l’output del seguente codice: public class TestDue { int prova = 0; public void aggiungi(int prova) { this.prova = prova + 10; } public static void main(String[] args) { int prova = 0; TestDue oggetto = new TestDue(); oggetto.aggiungi(100); System.out.println(prova); } } Prova1001100Question 3 of 10 4. Qual è il valore di a dopo aver eseguito l’istruzione a--, se a, all’inizio, vale 7? A. true B. 7 C. 6ABCQuestion 4 of 10 5. Qual è il risultato della seguente espressione: “1” + “3”? A. “4” B. “6” C. “13”ABCQuestion 5 of 10 6. Quale sarà l'output del seguente codice. class Base { public void show() { System.out.println("Base::show() called"); } } class Derived extends Base { public void show() { System.out.println("Derived::show() called"); } } public class Main { public static void main(String[] args) { Base b = new Derived();; b.show(); } } Derived::show() calledBase::show() calledQuestion 6 of 10 7. Qual'è l'output del seguente codice: public class Main { public static void main(String args[]) { int arr[] = {10, 20, 30, 40, 50}; for(int i=0; i < arr.length; i++) { System.out.print(" " + arr[i]); } } } Errore di Compilazione10, 20, 30, 40, 5010, 20, 30, 40Question 7 of 10 8. Quale sarà l'output del seguente codice: class Test { String str = "a"; void A() { try { str +="b"; B(); } catch (Exception e) { str += "c"; } } void B() throws Exception { try { str += "d"; C(); } catch(Exception e) { throw new Exception(); } finally { str += "e"; } str += "f"; } void C() throws Exception { throw new Exception(); } void display() { System.out.println(str); } public static void main(String[] args) { Test object = new Test(); object.A(); object.display(); } } abdefabdecErrore di compilazione abdefcQuestion 8 of 10 9. Quale sarà l'output del seguente codice. class Base { final public void show() { System.out.println("Base::show() called"); } } class Derived extends Base { public void show() { System.out.println("Derived::show() called"); } } class Main { public static void main(String[] args) { Base b = new Derived();; b.show(); } } Derived::show() calledBase::show() calledCompiler ErrorRuntime ErrorQuestion 9 of 10 10. Quale sarà l'output del programma: public class ThreadDemo { private int count = 1; public synchronized void doSomething() { for (int i = 0; i < 10; i++) System.out.println(count++); } public static void main(String[] args) { ThreadDemo demo = new ThreadDemo(); Thread a1 = new A(demo); Thread a2 = new A(demo); a1.start(); a2.start(); } } class A extends Thread { ThreadDemo demo; public A(ThreadDemo td) { demo = td; } public void run() { demo.doSomething(); } }Stampa i numeri da 0 a 19 in sequenza Stampa i numeri da 1 a 20 in sequenza Stampa i numeri da 1 a 20, ma l'ordine non può essere determinatoIl codice non verrà compilato.Question 10 of 10 Loading...
purtroppo le domande sono random e quindi non riesco a verificare se il punto 7 è errato. In ogni caso, grazie per la segnalazione Rispondi
Good
Quel ‘printf’ mi ha fottuto, carino il test.
forte bravo!
uauue bellissimo qst sito come ai fatto ? stupendo come quello di apple
ciao. è un template di wordpress.
Mi spiace ma il punto 7 é errato, genera un errore di compilazione
purtroppo le domande sono random e quindi non riesco a verificare se il punto 7 è errato. In ogni caso, grazie per la segnalazione