Java Programming Quiz


Play this Java quiz that will help you to excel in Java certification exams, placements etc. This Java programming quiz consist of 10 questions that you need to solve in 10 minutes. We’ve specially designed this quiz so that you can quickly acquaint to the pattern of questions you can be asked in placement drives, certification exams etc. This Java programming test enables you to assess your knowledge of Java programming.

Take the Free Practice Test



Java MCQs

Practice Java MCQ Questions, which will help you to understand Java programming related concepts and also helps you to prepare for placements, technical rounds, interviews, competitive exams etc.

Java Quiz

Try Free Java Quiz, to start a quiz you need to login first, after login you will get start quiz button and then by clicking on that you can start quiz. You will get 10 Minutes to answer all questions.

Java Quiz

1. What is the output of this program?

class Main
{
public static void main(String args[])
	{
		try
		{
			int a, b;
			b = 0;
			a = 5 / b;
			System.out.print("A");
		}
		catch(ArithmeticException e)
		{
			System.out.print("B");
		}
	}
}

A
B
Compilation Error
Runtime Error

2. What will be output for the folllowing code?

         
abstract class Bank {

  private abstract void withdraw(); // Line 1
  abstract void deposit();
  public void balance(){} //Line 2
}
class office extends Bank{ // Line 3

  void deposit() { // Line 4
    // TODO Auto-generated method stub

  }
}

Compilation error in Line 1(abstract method cannot be private)
Compilation error in Line 2(abstract class cannot have concrete method)
Compilation error in Line 3(abstract class cannot be extended)
Compilation error in Line 4(deposit method should have public access modifier)

3. Which of these keywords must be used to handle the exception thrown by try block in some rational manner?

finally
throw
catch
try

4. Thread priority in Java is?

Integer
Float
double
long

5. The super keyword is similar to _________ keyword.

construct
this
class
extends

6. Which of these keywords is used to manually throw an exception?

finally
throw
catch
try

7. Which annotation is used to represent command line input and assigned to correct data type?

@Input
@Variable
@Command Line
@Parameter

8. What will be output for the folllowing code?

abstract class Bank 
{

    private String bankName;

    Bank(String bankName) 
    {
        this.bankName = bankName;
    }

    public String getBankName() 
    {
    return bankName;
    }
}

class office extends Bank {

  office() {
    super("Axis Bank");
  }

  public static void main(String[] args) {
    Bank bank = new office();
    System.out.println(bank.getBankName());
  }

}

Compilation error will occur because ""abstract class cannot have constructor""
Compilation error will occur because ""abstract class must have an abstract method""
Compilation error will occur while invoking the super class constructor
Code will be compiled successfully

9. What will be the output of the program?

  
class Test { 
    public static void main(String[] args) {
      for(int i = 0; 0; i++) 
      {
          System.out.println(""Hello"");
          break; 
      } 
    } 
} 

Hello
Empty Output
Compiler error
Runtime error

10. Which of the following is an incorrect array declaration?

int [] arr = new int[5].
int arr[] = new int[5].
int arr[] = new int[5].
int arr[] = int [5] new

Results