Home » JAVA Programming » Modifier Types » Question
  1. What is the output of this program?

    public class Result
    {
    static void main(String args[])
    {
    int p , q = 1;
    p = 20;
    if(p != 20 && p / 0 == 0)
    System.out.println(q);
    else
    System.out.println(++q);
    }
    }
    1. 2
    2. 0
    3. Compilation error
    4. Runtime error
    5. None of these
Correct Option: C

main() method must be made public. Without main() being public java run time system will not be able to access main() and will not be able to execute the code.



Your comments will be displayed only after manual approval.