GoConqr has a new look! Let us know what you think.

Quiz

Java & Programming Quizz

gouber 8 questions 5.0 (1 rating)

Take the quiz

Questions in this quiz (8)

  1. 1You 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?
    1. ANo
    2. BYes
  2. 2Given 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)
    1. Anothing
    2. B"Running"
    3. CSyntax error
  3. 3Given the following code
    public class Run{

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



    }

    What gets returned (if anything does)
    1. A1
    2. B2
    3. C0001
    4. DSyntax Error
    5. ENothing
    6. Ftrue
  4. 4Given 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?
    1. A2
    2. B1
    3. CSyntax error
  5. 5Given 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
    1. A14
    2. B12
    3. CSyntax error
    4. D15
  6. 6In parallel & concurrent software final state is a must
    1. AYes
    2. BNo
  7. 7Which of the following blocks of code represent recursion?
    1. Apublic class Run{
      public Run(){

      recurse(1);
      }


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

      }
    2. Bpublic class Run{
      private int a = 0;

      public Run(){

      recurse(2);
      }


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

      }
  8. 8In 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 ).


    1. A2,1
    2. B2,1,0

Information

Description
Programming Quiz on Java and programming. Intermediate level
Author
gouber
Language
English
Views
188
Rating
5.0 out of 5 · 1 rating
Rate this quiz
Rate this quiz

Feedback

What is it about?

What do you think of the new look?

How do you like it?