Java Operators Quiz Online Test – 2

Java operators quiz 2 contains 10 single and multiple choice questions. Java operators quiz 2 questions are designed in such a way that it will help you understand Java Operators, 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) {
    		
    		long l1 = 30000;
    		long l2 = 10000;
    		
    		short s = 0;
    		
    		s += l1 + l2;
    		System.out.println(s);
    	}
    }
    
  2. What will happen when you compile and run the following code?

    class One{	
    }
    
    public class Test{
    	
    	static One one;
    	public static void main(String[] args) {
    		System.out.println(one instanceof One);	
    	}
    }
    
  3. Which of the following line will print true if written at line 15?

    interface Inter{}
    class One{}
    class Two extends One{}
    class Three extends Two implements Inter{}
    
    public class Test{
    	public static void main(String[] args) {
    		
    		One one = new Two();
    		Two two = new Three();
    		Three three = new Three();
    		Inter i = new Three();
    		
    		//your code here
    		
    	}
    }
    
  4. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args) {
    		long l = 20;
    		System.out.println(l instanceof Object);
    	}
    }
    
  5. What will happen when you compile and run the following code?

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

    public class Test{
    	
    	public static void main(String[] args) {
    		int i = 10;
    		if( i =< 15.5 )
    			System.out.println(true);
    		else
    			System.out.println(false);
    	}
    }
    
  7. What will happen when you compile and run the following code?

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

    public class Test{
    	
    	public static void main(String[] args) {
    		float[] f = {1.3f, 1.4f, 1.5f};
    		System.out.println( f instanceof Object );
    	}
    }
    
  9. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){
    		int i = 10;
    		int j = 20;
    		
    		if( i + j < 15 & i++ > 10 )
    			System.out.print(i);
    		else
    			System.out.print(i);
    		
    		int x = 10;
    		int y = 20;
    
    		if( x + y < 15 && x++ > 10 )
    			System.out.print(x);
    		else
    			System.out.print(x);
    
    	}	
    }
    
  10. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){			
    		
    		int i = 1;
    		int j = 2;
    		
    		int k = i + 10 * i++ - j * 5 + --j;
    		System.out.println(k);
    	}	
    }