Test Java Online

1. Quale sarà l'output del seguente codice:
public class Test implements Runnable 
{ 
  public void run() 
  { 
    System.out.printf(" Thread's running "); 
  } 

  try
  { 
    public Test() 
    { 
      Thread.sleep(5000); 
    } 
  } 
  catch (InterruptedException e) 
  { 
    e.printStackTrace(); 
  } 
  
  public static void main(String[] args) 
  { 
    Test obj = new Test(); 
    Thread thread = new Thread(obj); 
    thread.start(); 
    System.out.printf(" GFG "); 
  } 
} 
 

Question 1 of 10

2. 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);
    }
}
 

Question 2 of 10

3. Quale sarà l'output del seguente codice:

import java.io.IOException;

class Derived2 {
public void getDetails() throws IOException // line 6
{
System.out.println("Derived class");
}
}

public class Test extends Derived2 {
public void getDetails() throws Exception //line 13
{
System.out.println("Test class");
}

public static void main(String[] args) throws IOException //line 18
{
Derived2 obj = new Test();
obj.getDetails();

}
}
 

Question 3 of 10

4. Volendo rappresentare numeri con virgola mobile in Java, quali tipi primitivi si utilizzeranno?

Question 4 of 10

5. String a,b,c;
a = new String("1234");
b = a;
c = a +b

Quanti oggetti vengono creati?

Question 5 of 10

6. Quale sarà l’output prodotto dal seguente codice: 
class Base {
  public final 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();
    }
}
 

Question 6 of 10

7. Quale sarà l'output del seguente codice:
public class Test 
{ 
  private String function(float i, int f) 
  { 
    return ("gfg"); 
  } 
  private String function(double i, double f) 
  { 
    return ("GFG"); 
  } 
  public static void main(String[] args) 
  { 
    Test obj = new Test(); 
    System.out.println(obj.function(1., 20));	 
  } 
} 
 

Question 7 of 10

8.  

Dato il seguente codice, qual è l’output atteso?
int[] array = { 8, 3, 45, 6 };
for (int k = 0; k < 4; k++) {
    for (int i = 0; i < 3; i++) {
        int swap = 0;
        if (array[i] > array[i + 1]) {
            swap = array[i + 1];
            array[i + 1] = array[i];
            array[i] = swap;
        }
    }
}
System.out.println(array);
 

Question 8 of 10

9. Posso fare l'override di un metodo statico?

Question 9 of 10

10. Quale delle seguenti affermazioni sul costruttore di default è vera?

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 *