Skip to content

Java Language Basics Quiz Online Test – 1

Java language basics quiz 1 contains 10 single and multiple choice questions. Java language basics quiz 1 questions are designed in such a way that it will help you understand the fundamental concepts of Java. At the end of the quiz, result will be displayed along with your score and Java language basics quiz answers.

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

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

    public class Test{
    	
    	public static void main(String[] args){
    		
    		double d1 = Double.NaN;		
    		double d2 = d1;
    		
    		if(d1 == d2)
    			System.out.println("Equal");
    		else
    			System.out.println("Not Equal");
    	}
    	
    }
    
  2. 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 = 25;
    		System.out.println(i + ' ' + j);
    	}
    }
    
  3. 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 = 12;
    		i+=++j;
    		System.out.println(i);
    
    	}
    }
    
  4. What will happen when you compile and run the following code?

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

    public class Test{
    	
    	public static void main(String[] args){	
    		byte b1 = 5, b2 = 2;
    		byte b = b1 % b2;
    		System.out.println(b);
    	}
    }
    
  6. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){
    		
    		boolean b1 = true;
    		boolean b2 = true;
    
    		if(b1 == b2){
    			System.out.print("==");
    		}
    
    		if(b1.equals(b2)){
    			System.out.print("equals");
    		}
    	}
    }
    
  7. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){		
    		int array[] = new int[1];
    		array[0] = 100;
    
    		System.out.println(array.length());
    	}
    }
    
  8. What will happen when you compile and run the following code?

    public class Test{
    	
    	static String name = "Test";
    
    	public Test(){
    		name = "TestObject";
    	}
    	
    	public static void main(String[] args){	
    		System.out.println("Name is " + name);
    	}	
    }
    
  9. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args){
    		
    		float f = 10.2;
    		double d = 10.2;
    		
    		if(f == d)
    			System.out.println("Same");
    		else
    			System.out.println("Not same");		
    	}	
    }
    
  10. 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 );
    	}
    }