Java Language Basics Quiz Online Test – 5

Java language basics quiz 5 contains 10 single and multiple choice questions. Java language basics quiz 5 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. null is a valid keyword in Java

  2. A constructor can be final

  3. A transient variable can be static

  4. 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;
    		boolean b = getValue(i, j) ? true : false;
    		System.out.println(b);
    	}	
    	
    	public static boolean getValue(int i, int j){
    		return i > j;
    	}
    }
    
  5. 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);
    	}	
    	
    	public static void changeMe(int i){
    		i++;
    	}
    }
    
  6. What will happen when you compile and run the following code?

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

    public class Test{
    	
    	public static void main(String[] args){
    		boolean b = "false";
    		
    		if(b)
    			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){
    		int i = 10, j = 3;
    		int result = i/j;
    		
    		System.out.println(result);
    	}
    }
    
  9. What will happen when you compile and run the following code?

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

    public class Test{
    	
    	public static void main(String[] args){
    		int[] intarr = new int[2]{4, 5, 6};
    		for(int i = 0; i < intarr.length; i++)
    			System.out.print(intarr[i]);
    	}
    }