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. How many objects are eligible for garbage collection after execution of line 8?

  
public class Test
{
	public static void main(String [] args)
	{
		Test t1 = new Test();
		Test t2 = m1(t1); // line 6
		Test t3 = new Test();
		t2 = t3; // line 8
	}
	static Test m1(Test temp)
	{
		temp = new Test();
		return temp;
	}
}

0
1
2
3

2. Which of this access specifies can be used for a class so that its members can be accessed by a different class in the same package?

Public
Protected
No Modifier
All of the mentioned

3. All Java components require names. Names used for classes, variables, and methods are called?

Variables
identifiers
Access Modifiers
Java Modifiers

4. Which method is used to write an array of byte to the current output stream?

public void write(int)throws IOException
public void write(byte[])throws IOException
public void flush()throws IOException
public void close()throws IOException

5. Can 8 byte long data type be automatically type cast to 4 byte float data type?

TRUE
FALSE
Can be true or false
can not say

6. What is the output of this program?

  
class Output
{
	public static void main(String args[])
	{
		int x , y = 1;
		x = 10;
		if (x != 10 && x / 0 == 0)
			System.out.println(y);
		else
			System.out.println(++y);
	}
}		   

1
2
Runtime error owing to division by zero in if condition
Unpredictable behavior of program

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

finally
throw
catch
try

8. What is the order of precedence (highest to lowest) of following operators?
1. &
2. ^
3. ?:

1 -> 2 -> 3
2 -> 1 -> 3
3 -> 2 -> 1
2 -> 3 -> 1

9. What is true about time slicing?

Time slicing is OS service that allocates CPU time to available runnable thread
Time slicing is the process to divide the available CPU time to available runnable thread
Time slicing depends on its implementation in OS
Time slicing allocates more resources to thread

10. When is the Float object, created in line 3, eligible for garbage collection?

  
public Object m()
{
	Object o = new Float(3.14F);
	Object [] oa = new Object[l];
	oa[0] = o; /* Line 5 */
	o = null; /* Line 6 */
	oa[0] = null; /* Line 7 */
	return o; /* Line 8 */
}

just after line 5
just after line 6
just after line 7
just after line 8

Results