iGET

Java Programming - MCQ Practice Questions

Java interviews and campus tests lean heavily on object oriented behaviour rather than API recall. This set covers inheritance and polymorphism, interfaces and abstract classes, the collections framework, exception handling, multithreading, string handling, and JVM basics such as garbage collection. Output based questions are included because they expose the gaps that theory questions hide.

951 questions | 100% Free

Q.1Easy

Which of the following is the correct syntax to declare a variable in Java?

Q.2Easy

Which keyword is used to create a constant variable in Java?

Q.3Easy

What will be the output of the following code? int x = 5; x += 3; System.out.println(x);

Q.4Medium

Which of the following is NOT a primitive data type in Java?

Q.5Medium

What is the size of 'char' data type in Java?

Q.6Medium

Which of the following will compile without error? public static void main(String args[]) { int x = 10; final int y = 20; y = 30; }

Q.7Medium

What is the output of: System.out.println();

Q.8Medium

Which operator has the highest precedence in Java?

Q.9Medium

What is the output of: System.out.println(5 > 3 ? 'A' : 'B');

Q.10Medium

Which statement is correct about Java variables?

Q.11Hard

Consider the code: int a = 5; int b = a++; System.out.println(a + " " + b); What is the output?

Q.12Hard

What will be printed? System.out.println(10 + 20 + "Java");

Q.13Medium

Identify the output: System.out.println("Java".length());

Q.14Hard

What is the scope of a local variable in Java?

Q.15Medium

Which of the following is the correct way to declare and initialize an array in Java?

Q.16Easy

What will be the output of: boolean flag = true; System.out.println(!flag);

Q.17Hard

Consider: int x = 0; System.out.println(x == 0 && x != 1); What is the output?

Q.18Easy

What will be the output of: System.out.println();

Q.19Easy

Which keyword is used to prevent a class from being inherited?

Q.20Easy

Which of the following is a valid variable name in Java?