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. Single line comment starts with _________ in Java.

/**
//
/*
None of these

2. Methods used to obtain information about an object are known as?

string methods
class methods
object method
accessor methods

3. Which method causes the audio clip to replay continually?

public void play()
public void loop() 
public void stop()
None of the above

4. How to copy contents of array?

System.arrayCopy()
Array.copy()
Arrays.copy()
Collection.copy()

5. _________ are a sequence of characters.

Character
Strings
Integer
Classes

6. Which of the following will produce an answer that is closest in value to a double, d, while not being greater than d?

(int)Math.abs(d);
(int)Math.max(d);
(int)Math.min(d);
(int)Math.floor(d);

7. 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)

8. After line 11 runs, how many objects are eligible for garbage collection?

  
class X2
{
	public X2 x;
	public static void main(String [] args)
	{
		X2 x2 = new X2(); /* Line 6 */
		X2 x3 = new X2(); /* Line 7 */
		x2.x = x3;
		x3.x = x2;
		x2 = new X2();
		x3 = x2; /* Line 11 */
		doComplexStuff();
	}
}

0
1
2
3

9. What is the output of this program?

  
class Output
{
	public static void main(String args[])
	{
		boolean a = true;
		boolean b = false;
		boolean c = a ^ b;
		System.out.println(!c);
	}
}

0
1
FALSE
TRUE

10. Which of these exceptions will occur if we try to access the index of an array beyond its length?

ArithmeticException
ArrayException
ArrayIndexException
ArrayIndexOutOfBoundsException

Results