Conditional Statements

Q: What will be the output of the following program?
public class Main {
    public static void main(String[] args) {
        int a = 5;
        a +=5;
        switch(a)
        {
            case 5: 
            System.out.print("5");
            break;
            case 10: 
            System.out.print("10");
            System.out.println(((a%2 ==0) ? "-even-" : "-odd-"));  
            break;
            default: 
            System.out.print("0");
        }
    }
}
A: 10-even-
Q: Which of these are selection statements in Java?
A: if()
Q: Predict the output for the following code:
public class Main{
public static void main(String[] args){
  int a = -5;
  a +=5;
  switch(a)
  {
    case 5: 
        System.out.print("5");
        break;
    case 10: 
        System.out.print("10");
    default: 
        System.out.print("0");
    
  }
}
}
A: 0
Q: What will be the output of the following program?
public class Main {
    public static void main(String[] args) {
        int a = 0;
        a +=5;
        switch(a)
        {
            case 5: 
                System.out.print("5");
            case 10: 
                System.out.print("10");
            default: 
                System.out.print("0");
        }
    }
}
A: 5100
Q: Predict the output for the following code:
public class Main
{
    public static void main(String[] args)
    {
        int x = 10; 
        if (x) 
        { 
            System.out.println("Neostark"); 
        }
        else 
        { 
            System.out.println("Neo X"); 
        } 
    }
}
A: Compile time error
Q: What will be the output of the given code?
public class Main {
    public static void main(String[] args) 
    {
        boolean name = true;
        switch (name) 
        {
            case true:
                System.out.println("Hello ");
            default:
                System.out.println("hi");
        }
    }
}
A: Compilation error
Q: What will be the output of the following program?
class Main {
    public static void main(String[] args) {
        int a=15;
        int b=25;
        if ((a15)
            System.out.println(a);
        else
            System.out.println(b);
   }
}
A: 15
Q: What will be the output of the following program?
public class Main {
	public static void main(String[] args) {
        int x = 10; 
        final int y = 20; 
        switch (x) 
        { 
        case 10: 
            System.out.println("Neostark"); 
            break; 
        case y: 
            System.out.println("Neowise"); 
            break; 
        }
	}
}
A: Neostark
Q: What will be the output of the following code?
public class Main 
{
    public static void main(String[] args) 
    {
        int a = 0;
        a +=5;
        switch(a)
        {
            case 5: 
                System.out.print("5");
            case 10: 
                System.out.print("10");
                break;
            default: 
                System.out.print("0");
        }
    }
}
A: 510
Q: Predict the output for the following program:
public class Main
{
    public static void main(String[] args) 
    {
        int x=20;
        int y=10;
        if(x>y)
        {
        if (y>10)
            System.out.println("y is "+y);
        }
        else
            System.out.println("x is  "+x);
    }
}
A: No Output
Q: What will be the output of the following program?
public class Main {
    public static void main(String[] args) {
        int a = 5;
        a +=5;
        switch(a)
        {
        case 5: 
            System.out.println("5");
            break;
        case 10: 
            System.out.println("10");
            break;
        default: 
            System.out.println("0");
        }
    }
}
A: 10
Q: How many times is "student" printed?
public class Main
{
 public static void main(String[] args) 
   {
        do
        {
	    System.out.println("student");
      	}
      	while(false);
	}
}
A: 1
Q: The ____ statement provides an easy way to dispatch execution to different parts of your code based on the value of an expression.
A: switch
Q: What will be the output of the following program?
public class Main {
    public static void main(String[] args) {
      int a = 5;
      a +=5;
      switch(a)
      {
        case 5: 
            System.out.print("5");
            break;
        case 10: 
            System.out.print("10");
        default: 
            System.out.print("0");
      }
    }
}
A: 100
Q: Predict the output for the following code:
public class Main
{
    public static void main(String[] args)
    {
        int a = 5;
        a +=5;
        switch(a)
        {
            case 5: 
                System.out.print("5");
                break;
            case 10: 
                System.out.print("10");
                System.out.print(((a%2 ==0) ? "-even-" : "-odd-"));  
                default: 
                System.out.print("0");
        }
    }
}
A: 10-even-0