Test Java Online

1. Se la variabile c vale 2, data l’istruzione switch( c ){case 1: b =7; case 2: b=10;} quanto vale b dopo la sua esecuzione?
A. 10
B. 7
C. 17

Question 1 of 10

2. La passivazione/attivazione è una prerogativa degli ejb di tipo?

Question 2 of 10

3. Quale sarà l'output del seguente codice:
class Base 
{ 
  public static String s = " Super Class "; 
  public Base() 
  { 
    System.out.printf("1"); 
  } 
} 
public class Derived extends Base 
{ 
  public Derived() 
  { 
    System.out.printf("2"); 
    super(); 
  } 
  
  public static void main(String[] args) 
  { 
    Derived obj = new Derived(); 
    System.out.printf(s); 
  } 
} 
 

Question 3 of 10

4. 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")

Question 4 of 10

5. Quale sarà l’output prodotto dal seguente codice:
import java.io.*; 
public class Test 
{ 
  public void display() throws IOException 
  { 
    System.out.println("Test"); 
  } 

} 

class Derived extends Test 
{ 
  public void display() throws IOException 
  { 
    System.out.println("Derived"); 
  } 
  public static void main(String[] args) throws IOException 
  { 
    Derived object = new Derived(); 
    object.display(); 
  } 
} 
 

 

Question 5 of 10

6. Quale sarà l'output?
public class If1 
{
    static boolean b;
    public static void main(String [] args) 
    {
        short hand = 42;
        if ( hand < 50 && !b ) /* Line 7 */
            hand++;
        if ( hand > 50 );     /* Line 9 */
        else if ( hand > 40 ) 
        {
            hand += 7;
            hand++;    
        }
        else
            --hand;
        System.out.println(hand);
    }
}

Question 6 of 10

7. Quali valori di “i” stamperà il seguente codice: for (int i = 0; i < 10; i++) { System.out.println(i); }
A. Non stampa nulla
B. Stampa i numeri da 0 a 9
C. Stampa i numeri da 0 a 10

Question 7 of 10

8. Qual è il risultato della seguente espressione, se a vale 9: a * 3?
A. 27
B. 3a;
C. Genera un errore;

Question 8 of 10

9. Dato il seguente codice, qual è l’output atteso?

 
String prova = "prova";
prova.concat(" aggiungo una stringa");
System.out.println(prova);
 

Question 9 of 10

10. Quale sarà l'output del seguente codice:
class Derived 
{ 
  public void getDetails(String temp) 
  { 
    System.out.println("Derived class " + temp); 
  } 
} 

public class Test extends Derived 
{ 
  public int getDetails(String temp) 
  { 
    System.out.println("Test class " + temp); 
    return 0; 
  } 
  public static void main(String[] args) 
  { 
    Test obj = new Test(); 
    obj.getDetails("GFG"); 
  } 
} 
 

Question 10 of 10


 

7 risposte a “Test Java Online”

    1. purtroppo le domande sono random e quindi non riesco a verificare se il punto 7 è errato. In ogni caso, grazie per la segnalazione

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *