40 UIL Computer Science generated by Joe Cusack September 2023 **Multiple Choice:** 1. Which of the following data structures is LIFO? - A. Queue - B. Array - C. Stack - D. LinkedList 2. Which of the following is not an O(n log n) sorting algorithm? - A. Merge Sort - B. Quick Sort - C. Bubble Sort - D. Heap Sort 3. Which of the following is not a primitive data type in Java? - A. char - B. int - C. float - D. String 4. The primary purpose of a constructor in a class is to: - A. Delete objects - B. Initialize objects - C. Copy objects - D. Rename objects 5. How many bytes does a `double` data type use in Java? - A. 4 - B. 6 - C. 8 - D. 16 6. Which of these is a valid way to declare an integer array in Java? - A. int array[] = {1,2,3,4}; - B. int[] array = (1,2,3,4); - C. array{} = int[4]; - D. array[4] = int{1,2,3,4}; 7. Which data structure uses a key-value pair? - A. LinkedList - B. Stack - C. Hashtable - D. Queue 8. In object-oriented programming, what concept represents the real-world entities? - A. Inheritance - B. Encapsulation - C. Objects - D. Polymorphism 9. What does the `finally` block in Java signify? - A. It always runs after a try block - B. It runs when there's an exception - C. It's an alternative to the catch block - D. It only runs after a catch block 10. Which of the following loops will execute at least once? - A. for - B. while - C. do-while - D. foreach 11. Which of the following access specifiers allows visibility within the same package only? - A. private - B. public - C. protected - D. default 12. Which algorithm is best suited for searching in a sorted list? - A. Linear Search - B. Binary Search - C. Depth-First Search - D. Breadth-First Search 13. The big O notation for the best case of QuickSort is: - A. O(1) - B. O(n log n) - C. O(n^2) - D. O(n) 14. Which data structure can be used to implement both a stack and a queue? - A. Array - B. LinkedList - C. Binary Tree - D. Graph 15. Which of the following operations is not supported by arrays in Java? - A. Insertion - B. Deletion - C. Resize - D. Access 16. What is the full form of OOP? - A. Ordered Object Programming - B. Objective Oriented Programming - C. Object Oriented Project - D. Object Oriented Programming 17. Which of the following is a recursive data structure? - A. Array - B. Stack - C. Queue - D. Tree 18. Which of the following concepts makes Java platform independent? - A. Encapsulation - B. Bytecode - C. Overloading - D. Overriding 19. How many primary threads does a Java program have by default? - A. 0 - B. 1 - C. 2 - D. It depends on the program. 20. In which memory area, Java stores local variables? - A. Stack - B. Queue - C. Heap - D. Registers Word Bank: Abstract Encapsulation Java length Method Overloading Object-Oriented Modeling Runtime Polymorphism or Dynamic Polymorphism Subclass throw Throwable **Fill in the Blanks:** 21. A class that is derived from another class is called a ________. 22. In Java, ________ is the base class for all exceptions. 23. ________ allows a class to implement multiple interfaces but extend only one class. 24. A class whose objects cannot be instantiated is known as a ________ class. 25. The keyword used to manually throw an exception in Java is ________. 26. The process of mapping real-world entities directly to a programming language is known as ________. 27. When a class hides its internal data from the outside world and only exposes operations to interact with it, it's called ________. 28. ________ is a type of polymorphism achieved at runtime. 29. The size of an array in Java can be determined using the ________ property. 30. When two or more methods in the same class have the same name but different parameters, it is called ________. **True or False:** 31. In Java, a class can extend multiple classes. 32. Encapsulation helps in binding the code and data together. 33. All methods in Java need to be part of a class. 34. A Java program can run without a main method. 35. The process of obtaining one interface from another interface is known as multiple inheritances. 36. The array indices start from 0 in Java. 37. Static binding uses information available at compile time. 38. Constructor overloading is not possible in Java. 39. In a try-catch block, the catch block can be written before the try block. 40. Garbage collection in Java is done manually by the programmer.