Objects and Collections Questions and Answers

Take Exam

Java Objects and Collections programming questions and answers are essential for mastering object-oriented design and data structure handling. These questions often appear in coding interviews by Infosys, TCS, and Accenture. The topic covers object creation, reference handling, garbage collection, and the use of Java Collection Framework classes like List, Set, and Map. Understanding how to manage and iterate over collections efficiently helps in building optimized programs. Practicing programming questions and answers in this area enhances both logic and coding speed—crucial skills for clearing technical interview rounds and online assessments.

Objects and Collections

Showing 10 of 38 questions

11. /* Missing Statement ? */ public class foo {     public static void main(String[]args)throws Exception     {         java.io.PrintWriter out = new java.io.PrintWriter();         new java.io.OutputStreamWriter(System.out,true);         out.println("Hello");     } } What line of code should replace the missing statement to make this program compile?

  • No statement required.
  • import java.io.*;
  • include java.io.*;
  • import java.io.PrintWriter;
Show Answer Report

12. What is the numerical range of char?

  • 0 to 32767
  • 0 to 65535
  • -256 to 255
  • -32768 to 32767
Show Answer Report

13. Which of the following are Java reserved words?     run     import     default     implement

  • 1 and 2
  • 2 and 3
  • 3 and 4
  • 2 and 4
Show Answer Report

14. Which keyword is used to create an object in Java?

  • class
  • new
  • this
  • object
Show Answer Report

15. Which method is called automatically when an object is created?

  • finalize()
  • start()
  • constructor
  • main()
Show Answer Report

16. Which collection class stores elements in key-value pairs?

  • List
  • Set
  • Map
  • Queue
Show Answer Report

17. Which interface allows duplicate elements?

  • Set
  • Map
  • List
  • Iterator
Show Answer Report

18. Which class is synchronized?

  • ArrayList
  • LinkedList
  • Vector
  • HashSet
Show Answer Report

19. Which of the following guarantees unique elements?

  • ArrayList
  • HashSet
  • LinkedList
  • Vector
Show Answer Report

20. Which method is used to compare two strings?

  • compare()
  • equals()
  • match()
  • same()
Show Answer Report
Questions and Answers for Competitive Exams Various Entrance Test