Java Operators Quiz Online Test – 3

Java operators quiz 3 contains 12 single and multiple choice questions. Java operators quiz 3 questions are designed in such a way that it will help you understand how to use Java Operators, their precedence and associativity. At the end of the quiz, result will be displayed along with your score and Java operators quiz answers.

There is no time limit to complete the quiz. Click Start Quiz button to start the Java operators quiz online.

  1. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args) {
    		int i = 5, j = 8, k = 0;
    		
    		if(i > j && i++ < 10 && (k += i + j) > 10){
    			System.out.print("true");
    		}
    		
    		System.out.print(i);
    		System.out.print(j);
    		System.out.print(k);
    	}
    }
    
  2. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args) {
    		int i = 1, j = 1, k = 1;
    		if( i++ > 1 && j++ < 2 || k++ == 1 )
    			System.out.print(1);
    		else
    			System.out.print(2);
    
    		System.out.print(i);
    		System.out.print(j);
    		System.out.print(k);
    	}
    }
    
  3. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args) {
    		int i = 50, j = 10;
    		int k = i + 10 / j;
    		System.out.println(k);
    	}
    }
    
  4. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args) {
    		int i = 12, j = 3;
    		int k = i / j * 2;
    		System.out.println(k);
    	}
    }
    
  5. The && operator always evaluates both operands.

  6. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){		
    		int i = 0;
    		System.out.println(~i);
    	}		
    }
    
  7. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){		
    		int i = 2;
    		System.out.println(i << 3);
    	}		
    }
    
  8. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){		
    		int i = 32;
    		System.out.println(i >> 3);
    	}		
    }
    
  9. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){
    		int i = -32;
    		System.out.println(i>>>3);
    	}
    }
    
  10. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){		
    		int i = 10, j = 5;
    		System.out.println(i & j);
    	}
    }
    
  11. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){		
    		int i = 5, j = 2;
    		System.out.println(i | j);
    	}
    }
    
  12. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){		
    		int i = 5, j = 3;
    		System.out.println(i ^ j);
    	}
    }