Skip to content

Java Language Basics Quiz Online Test – 4

Java language basics quiz 4 contains 10 single and multiple choice questions. Java language basics quiz 4 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) {
    		
    		byte b1 = 10, b2 = 5;
    		byte b3 = b1 / b2;		
    		System.out.println(b3);
    	}
    }
    
  2. What will happen when you compile and run the following code?

    public class Test{
    	
    	public static void main(String[] args) {
    		
    		byte b1 = 100, b2 = 28;
    		byte b3 = (byte) (b1+b2);		
    		System.out.println(b3);
    	}
    }
    
  3. Which of the following lines will compile successfully if written at line 4?

    public class Test{
    	
    	public static void main(String[] args) {
    		//your code here
    	}
    }
    
  4. What are the correct syntaxes of the main method?

  5. Which of the below given variable names are valid in Java?

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

    public class Test{
    	
    	public static void main(String[] args){			
    		
    		int try = 3;
    		for( int i = 0; i < try; i++){
    			System.out.print("Try" + i + " ");
    		}		
    	}	
    }
    
  7. Which of the following are Java keywords?

  8. Which of the following are Java keywords?

  9. Which of the following are NOT Java keywords?

  10. What should be the type of the variable join in the following code at line 10?

    public class Test{
    	
    	public static void main(String[] args){
    		
    		byte b = 20;
    		char c = 'a';
    		int i = 10;
    		float f = 20.2f;
    		
    		join = b + c + i + f;
    	}
    }