gouber
Test por , creado hace más de 1 año

Programming Quiz on Java and programming. Intermediate level

122
3
0
gouber
Creado por gouber hace más de 9 años
Cerrar

Java & Programming Quizz

Pregunta 1 de 8

1

You find the following code in a file called Quiz.java

public class Question1{

public static void main(String[] args){
System.out.println("Code reached this point");
}

}

Does the code run?

Selecciona una de las siguientes respuestas posibles:

  • No

  • Yes

Explicación

Pregunta 2 de 8

1

Given the following block of code.
public class Run {


public Run(){
run_for_me(new Runnable(){
public void run(){
System.out.println("Running");
}
});
}

public static void main(String[] args){
new Run();
}

public void run_for_me(Runnable run){
run.run();
}

}
What gets printed on the console? (Note: The code might not be syntactically correct)

Selecciona una de las siguientes respuestas posibles:

  • nothing

  • "Running"

  • Syntax error

Explicación

Pregunta 3 de 8

1

Given the following code
public class Run{

public static void main(String[] args){
System.out.println(1 << 1);
}

}

What gets returned (if anything does)

Selecciona una de las siguientes respuestas posibles:

  • 1

  • 2

  • 0001

  • Syntax Error

  • Nothing

  • true

Explicación

Pregunta 4 de 8

1

Given the following code:
public class Run{

public static void main(String[] args){
int a = 1 + run();
System.out.println(a);
}

public int run(){
return 1;
}

}

What does the last line of code print?

Selecciona una de las siguientes respuestas posibles:

  • 2

  • 1

  • Syntax error

Explicación

Pregunta 5 de 8

1

Given the following code:
public class Run{

private static final int ARRAY_SIZE = 12;

public Run(){
ARRAY_SIZE += 1;
int h = ARRAY_SIZE + 2;
}

}

What is the value of h

Selecciona una de las siguientes respuestas posibles:

  • 14

  • 12

  • Syntax error

  • 15

Explicación

Pregunta 6 de 8

1

In parallel & concurrent software final state is a must

Selecciona una de las siguientes respuestas posibles:

  • Yes

  • No

Explicación

Pregunta 7 de 8

1

Which of the following blocks of code represent recursion?

Selecciona una de las siguientes respuestas posibles:

  • public class Run{
    public Run(){

    recurse(1);
    }

    public int recurse(int n){
    if(n == 10){
    return 10;
    }else{
    recurse(n+1);
    }
    return 0;
    }

    }

  • public class Run{
    private int a = 0;

    public Run(){

    recurse(2);
    }

    public void recurse(int n){
    a = n;
    }

    }

Explicación

Pregunta 8 de 8

1

In parallel execution where memory is shared (and code "buggy") given the following piece of code
async { x = x + 1 }
async { x = x * 2 }

What are the possible values of x?

NOTE ( "async is not a valid call in Java however think of it as the two statements being run in parallel ).

Selecciona una de las siguientes respuestas posibles:

  • 2,1

  • 2,1,0

Explicación