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. _______ is not a flow control statement in Java.

break
continue
exit()
return

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

@Input
@Variable
@Command Line
@Parameter

3. The static method Thread.currentThread() returns a reference to the currently executing Thread object. What is the result of this code?

  	  
class Test
{
	public static void main(String [] args)
	{
		printAll(args);
	}
	public static void printAll(String[] lines)
	{
		for(int i = 0; i < lines.length; i++)
		{
			System.out.println(lines[i]);
			Thread.currentThread().sleep(1000);
		}
	}
}

Each String in the array lines will output, and there is no guarantee there will be a pause because currentThread() may not retrieve this thread.
Each String in the array lines will output, with no pause in between because this method is not executed in a Thread.
Each String in the array lines will output, with a 1-second pause.
This code will not compile.

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

finally
throw
catch
try

5. Which interface is used to execute SQL statements in Java?

java.sql.Statement
java.sql.Connection
java.sql.ResultSet
java.sql.PreparedStatement

6. In the following code snippet, which lines of code contain error?

int j=0;
while (j < 10)
{
	j++;
	if (j==5) continue loop;
	system.out.ptintln("j is " +j);
}

Line 2
Line 3
Line 4
Line 5

7. An abstract class can have a data member, abstract method, method body (non-abstract method), constructor, and even main() method.

TRUE
FALSE
Can be true or false
can not say

8. Which will contain the body of the thread?

main();
stop();
start();
run();

9. Abstract class can have constructors and static methods?

TRUE
FALSE
Abstract class can have constructors but can not have static methods.
Abstract class can not have constructors but can have static methods.

10. Which of the following packages is used to includes utility classes like Calendar, Collection, Date?

java.lang
java.net
java.awt
java.util

Results