1. Question: Methods must include all of the following except - 

    A
    a declaration

    B
    a call to another method

    C
    curly braces

    D
    a body


    1. Twitter
    2. Details
  2. Question: All method declaration must contain - 

    A
    the keyword "static"

    B
    one or more aceess modifiers

    C
    arguments

    D
    parantheses


    1. Twitter
    2. Details
  3. Question: Which of the method declarations is correct for a method named displayFacts() if the method receives an int argument? 

    A
    public void int displayFacts()

    B
    public void displayFacts(int)

    C
    public void displayFacts(int data)

    D
    public void displayFacts()


    1. Twitter
    2. Details
  4. Question: The information provided within the parenthesis is called arguments

    A
    False

    B
    True


    1. Twitter
    2. Details
  5. Question: Arguments are optional in any method. 

    A
    True

    B
    False


    1. Twitter
    2. Details
  6. Question: A method is a series of statements that carry out a task. 

    A
    True

    B
    False


    1. Twitter
    2. Details
  7. Question: What will be the output of the program? public class Test { public static void main(String[] args) { int x = 0; assert (x > 0) ? "assertion failed" : "assertion passed" ; System.out.println("finished"); } } 

    A
    finished

    B
    Compiliation fails.

    C
    An AssertionError is thrown and finished is output.

    D
    An AssertionError is thrown with the message "assertion failed."


    1. Twitter
    2. Details
  8. Question: public class Test { public void foo() { assert false; /* Line 5 */ assert false; /* Line 6 */ } public void bar() { while(true) { assert false; /* Line 12 */ } assert false; /* Line 14 */ } } What causes compilation to fail? 

    A
    Line 5

    B
    Line 6

    C
    Line 12

    D
    Line 14


    1. Twitter
    2. Details
  9. Question: What will be the output of the program? public class Test { public static int y; public static void foo(int x) { System.out.print("foo "); y = x; } public static int bar(int z) { System.out.print("bar "); return y = z; } public static void main(String [] args ) { int t = 0; assert t > 0 : bar(7); assert t > 1 : foo(8); /* Line 18 */ System.out.println("done "); } } 

    A
    bar

    B
    bar done

    C
    foo done

    D
    Compilation fails


    1. Twitter
    2. Details
  10. Question: What will be the output of the program (when you run with the -ea option) ? public class Test { public static void main(String[] args) { int x = 0; assert (x > 0) : "assertion failed"; /* Line 6 */ System.out.println("finished"); } } 

    A
    finished

    B
    Compilation fails.

    C
    An AssertionError is thrown.

    D
    An AssertionError is thrown and finished is output.


    1. Twitter
    2. Details