Decision Making


  1. Which of the following is not a valid jump statement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: D

    break, continue and return transfer control to another part of the program and returns back to caller after execution. However, goto is marked as not used in Java.


  1. Which of the following is not a decision making statement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: B

    do-while is an iteration statement. Others are decision making statements.



  1. What is the valid data type for variable “a” to print “Interview Mania”?

    switch(p)
    {
    System.out.println("Interview Mania");
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    The switch condition would only meet if variable “a” is of type byte or char.


  1. Which of the following is used with the switch statement?











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: A

    Break is used with a switch statement to shift control out of switch.



  1. What would be the output of the following codesnippet if variable p=20?

    public class Result
    {
    public static void main(String args[])
    {
    int p=20;
    if(p<=0)
    {
    if(p==0)
    {
    System.out.println("5 ");
    }
    else
    {
    System.out.println("10 ");
    }
    }
    System.out.println("15 ");
    }
    }











  1. View Hint View Answer Discuss in Forum

    NA

    Correct Option: C

    Since the first if condition is not met, control would not go inside if statement and hence only statement after the entire if block will be executed.