iGET

Java Programming - MCQ Practice Questions

Practice free Java Programming multiple-choice questions with detailed answers and explanations. Perfect for competitive exam preparation.

958 questions | 100% Free

Q.41Medium

Which statement about constructors is INCORRECT?

Q.42Medium

Which of the following correctly represents variable declaration and initialization in Java?

Q.43Medium

Which of the following will compile and run without errors?

Q.44Medium

Which method is called automatically when an object is garbage collected?

Q.45Medium

What will be the output of the following code? String str1 = "Hello"; String str2 = new String("Hello"); System.out.println(str1 == str2);

Q.46Medium

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?

Q.47Medium

Which of the following correctly demonstrates method overloading in Java?

Q.48Medium

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?

Q.49Medium

Which of the following statements about Java's String class is TRUE?

Q.50Medium

In Java, what is the relationship between an interface and a class in terms of implementation?

Q.51Medium

What is the output of the following code? class A { int x = 10; } class B extends A { int x = 20; } public class Test { public static void main(String[] args) { A obj = new B(); System.out.println(obj.x); } }

Q.52Medium

Which of the following statements about abstract classes is TRUE?

Q.53Medium

What will happen when you try to instantiate an interface in Java?

Q.54Medium

Which of the following best describes encapsulation?

Q.55Medium

Which of the following is true about method overloading?

Q.56Medium

What is the correct way to prevent a class from being inherited in Java?

Q.57Medium

What is the output? class A { A() { System.out.println("A"); } } class B extends A { B() { super(); System.out.println("B"); } } public class Test { public static void main(String[] args) { new B(); } }

Q.58Medium

Which of the following statements about 'instanceof' operator is correct?

Q.59Medium

Which of the following statements about inheritance in Java is correct?

Q.60Medium

Which of the following correctly describes method overriding in Java?