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 will be the output of the following code snippet?

  
int a=15;
int b=25;
if ((a < b ) || ( a = 5)>15)
	system.out.println(a);
else
	system.out.println(b);

Error
15
25
No output

2. Which of the following is false statement about package in java?

Packages are used for preventing naming conflicts
Providing controlled access: protected and default have package level access control.
Packages cannot be considered as data encapsulation
Both B and C

3. What is the valid data type for variable "a" to print "Hello World"?

switch(a)
{
   System.out.println("Hello World");
}

int and float
byte and short
char and long
byte and char

4. Which of the following are legal lines of Java code?
1. int w = (int)888.8;
2. byte x = (byte)100L;
3. long y = (byte)100;
4. byte z = (byte)100L;

1 and 2
2 and 3
3 and 4
All statements are correct

5. What will be the output of the program?

  
class Main {  
   public static void main(String args[]) {    
         int t; 
         System.out.println(t);
    } 
}

0
garbage value
compiler error
runtime error

6. Which of the below is not a Java Profiler?

JVM
JProfiler
JConsole
Eclipse Profiler

7. What will be output for the following code?

class Main
{
public static void main(String args[])
	{
		int arr[] = new int[] {0 , 1, 2, 3, 4, 5, 6, 7, 8, 9};
		int n = 6;
		n = arr[arr[n] / 2];
		System.out.print(n);
	}	
}

3
0
6
1

8. What will be the output of the program?

class Main
{
 public static void main (String[] args)
	{
		int arr1[] = {1, 2, 3};
		int arr2[] = {1, 2, 3};
		if (arr1 == arr2)
			System.out.println("Same");
		else
			System.out.println("Not same");
	}
}

Same
Not Same
Compiler error
None of the above

9. What will be output for the following code?

  
class Test {
	public static void main(String args[]) {
		int arr[] = new int[2];
		System.out.println(arr[0]);
		System.out.println(arr[1]);
	}
}

0 0
garbage value garbage value
Compiler Error
Exception

10. What is the output of this program?

  
class operators
{
	public static void main(String args[])
	{
		int var1 = 5;
		int var2 = 6;
		int var3;
		var3 = ++ var2 * var1 / var2 + var2;
		System.out.print(var3);
	}
}

10
11
12
56

Results