IT Basics MCQs set 2 for PU CET Lahore (Engineering & CS) computer science — 20 solved questions.
Q1. What is the time complexity of Bubble Sort?
Answer: O(n²)
Explanation: Bubble Sort has a worst-case time complexity of O(n²) due to its nested loop structure, making it less efficient for large datasets.
Q2. What is the purpose of DNS?
Answer: To translate domain names to IP addresses
Explanation: DNS translates human-readable domain names into IP addresses that computers can understand, facilitating communication over the internet.
Q3. What is the primary advantage of using a relational database?
Answer: Support for transactions
Explanation: Relational databases support transactions, ensuring data consistency and integrity by allowing multiple operations to be executed as a single, all-or-nothing unit.
Q4. What is the difference between a process and a thread?
Answer: A thread is a lightweight process
Explanation: A thread is a lightweight process that shares the same memory space as other threads within a process, making it more efficient for concurrent execution.
Q5. What is the difference between a stack and a queue?
Answer: A stack is LIFO, while a queue is FIFO
Explanation: A stack follows the Last-In-First-Out (LIFO) principle, while a queue follows the First-In-First-Out (FIFO) principle, making them suitable for different applications.
Q6. What is the purpose of a SQL join?
Answer: To combine data from multiple tables
Explanation: A SQL join is used to combine data from multiple tables based on a common column, allowing for more complex queries and data analysis.
Q7. What is the time complexity of Insertion Sort?
Answer: O(n²)
Explanation: Insertion Sort has a worst-case time complexity of O(n²) due to its iterative approach, making it less efficient for large datasets.
Q8. What is the purpose of a hash table?
Answer: To provide fast lookup and insertion operations
Explanation: A hash table provides fast lookup and insertion operations by mapping keys to indices using a hash function, making it efficient for data storage and retrieval.
Q9. What is the difference between a local variable and a global variable?
Answer: A local variable is accessible only within a specific scope, while a global variable is accessible throughout the program
Explanation: A local variable is declared within a specific scope and is accessible only within that scope, while a global variable is declared outside any scope and is accessible throughout the program.
Q10. What is the purpose of a try-catch block?
Answer: To handle runtime errors
Explanation: A try-catch block is used to handle runtime errors by catching exceptions and executing alternative code, preventing program crashes and improving robustness.
Q11. What is the time complexity of Quick Sort?
Answer: O(n log n)
Explanation: Quick Sort has an average-case time complexity of O(n log n) due to its divide-and-conquer approach, making it efficient for large datasets.
Q12. What is the result of the expression 7 mod 3?
Answer: 1
Explanation: The modulus operator (mod) returns the remainder of the division of 7 by 3, which is 1.
Q13. Which sorting algorithm is known for its stability?
Answer: Merge Sort
Explanation: Merge Sort is a stable sorting algorithm, maintaining the relative order of equal elements.
Q14. Which data structure is used to implement a recursive function?
Answer: Stack
Explanation: A stack is used to implement recursive functions, as it follows the LIFO principle, allowing for the correct order of function calls and returns.
Q15. What is the purpose of a DNS server?
Answer: To translate domain names into IP addresses
Explanation: A DNS (Domain Name System) server translates domain names into IP addresses, enabling users to access websites and other online resources using easy-to-remember domain names.
Q16. Which of the following is a characteristic of a cloud computing model?
Answer: Scalability and on-demand resources
Explanation: Cloud computing models offer scalability and on-demand resources, allowing users to quickly adapt to changing needs without managing underlying infrastructure.
Q17. What is the primary advantage of using a linked list?
Answer: Dynamic memory allocation
Explanation: Linked lists allow for dynamic memory allocation, as elements can be added or removed without requiring a fixed amount of contiguous memory.
Q18. What is the purpose of the 'super' keyword in Java?
Answer: To access superclass members
Explanation: The 'super' keyword is used to access members of the superclass from a subclass, allowing for code reuse and facilitating inheritance.
Q19. What is the purpose of a hash function?
Answer: To map data to a fixed-size index
Explanation: A hash function maps input data of any size to a fixed-size index, enabling efficient storage and retrieval of data in a hash table.
Q20. What is the purpose of the 'this' keyword in Java?
Answer: To refer to the current object
Explanation: The 'this' keyword refers to the current object of the class, allowing for access to its members and resolution of naming conflicts.