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
Which statement about constructors is INCORRECT?
Which of the following correctly represents variable declaration and initialization in Java?
Which of the following will compile and run without errors?
Which method is called automatically when an object is garbage collected?
What will be the output of the following code?
String str1 = "Hello";
String str2 = new String("Hello");
System.out.println(str1 == str2);
Consider a scenario where you need to create a variable that can hold references to objects of any type. Which of the following approaches would be most appropriate in Java 2024 standards?
Which of the following correctly demonstrates method overloading in Java?
Consider a real-world scenario where you need to implement a logging system. Which access modifier would you use for internal helper methods that should not be accessible outside the class?
Which of the following statements about Java's String class is TRUE?
In Java, what is the relationship between an interface and a class in terms of implementation?