PU CET Lahore (Engineering & CS) computer science IT Basics — Set 2

IT Basics MCQs set 2 for PU CET Lahore (Engineering & CS) computer science — 20 solved questions.

PU CET Lahore (Engineering & CS) computer science IT Basics — Set 2

  1. Question 1

    Q1. What is the time complexity of Bubble Sort?

    • A) O(n)
    • B) O(n log n)
    • C) O(n²)
    • D) O(2^n)

    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.

  2. Question 2

    Q2. What is the purpose of DNS?

    • A) To translate domain names to IP addresses
    • B) To translate IP addresses to domain names
    • C) To route packets across the internet
    • D) To provide network security

    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.

  3. Question 3

    Q3. What is the primary advantage of using a relational database?

    • A) Flexibility in data modeling
    • B) High performance for complex queries
    • C) Ability to handle large amounts of unstructured data
    • D) Support for transactions

    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.

  4. Question 4

    Q4. What is the difference between a process and a thread?

    • A) A process is a lightweight thread
    • B) A thread is a lightweight process
    • C) A process is used for I/O operations, while a thread is used for CPU-intensive tasks
    • D) A process is used for CPU-intensive tasks, while a thread is used for I/O operations

    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.

  5. Question 5

    Q5. What is the difference between a stack and a queue?

    • A) A stack is FIFO, while a queue is LIFO
    • B) A stack is LIFO, while a queue is FIFO
    • C) A stack is used for recursive algorithms, while a queue is used for iterative algorithms
    • D) A stack is used for dynamic memory allocation, while a queue is used for static memory allocation

    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.

  6. Question 6

    Q6. What is the purpose of a SQL join?

    • A) To combine data from multiple tables
    • B) To filter data based on conditions
    • C) To sort data in ascending or descending order
    • D) To group data by categories

    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.

  7. Question 7

    Q7. What is the time complexity of Insertion Sort?

    • A) O(n)
    • B) O(n log n)
    • C) O(n²)
    • D) O(2^n)

    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.

  8. Question 8

    Q8. What is the purpose of a hash table?

    • A) To store data in a sorted order
    • B) To store data in a compressed format
    • C) To provide fast lookup and insertion operations
    • D) To store data in a secure manner

    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.

  9. Question 9

    Q9. What is the difference between a local variable and a global variable?

    • A) A local variable is accessible throughout the program, while a global variable is accessible only within a specific scope
    • B) A local variable is accessible only within a specific scope, while a global variable is accessible throughout the program
    • C) A local variable is used for dynamic memory allocation, while a global variable is used for static memory allocation
    • D) A local variable is used for static memory allocation, while a global variable is used for dynamic memory allocation

    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.

  10. Question 10

    Q10. What is the purpose of a try-catch block?

    • A) To handle runtime errors
    • B) To optimize code performance
    • C) To improve code readability
    • D) To reduce code complexity

    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.

  11. Question 11

    Q11. What is the time complexity of Quick Sort?

    • A) O(n)
    • B) O(n log n)
    • C) O(n²)
    • D) O(2^n)

    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.

  12. Question 12

    Q12. What is the result of the expression 7 mod 3?

    • A) 2
    • B) 1
    • C) 0
    • D) 3

    Answer: 1

    Explanation: The modulus operator (mod) returns the remainder of the division of 7 by 3, which is 1.

  13. Question 13

    Q13. Which sorting algorithm is known for its stability?

    • A) Quick Sort
    • B) Merge Sort
    • C) Heap Sort
    • D) Selection Sort

    Answer: Merge Sort

    Explanation: Merge Sort is a stable sorting algorithm, maintaining the relative order of equal elements.

  14. Question 14

    Q14. Which data structure is used to implement a recursive function?

    • A) Stack
    • B) Queue
    • C) Tree
    • D) Graph

    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.

  15. Question 15

    Q15. What is the purpose of a DNS server?

    • A) To translate domain names into IP addresses
    • B) To provide network connectivity
    • C) To optimize network performance
    • D) To manage network resources

    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.

  16. Question 16

    Q16. Which of the following is a characteristic of a cloud computing model?

    • A) On-premises infrastructure
    • B) Scalability and on-demand resources
    • C) Dedicated hardware
    • D) Manual software updates

    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.

  17. Question 17

    Q17. What is the primary advantage of using a linked list?

    • A) Efficient indexing
    • B) Dynamic memory allocation
    • C) Fast search times
    • D) Cache-friendly access

    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.

  18. Question 18

    Q18. What is the purpose of the 'super' keyword in Java?

    • A) To access subclass members
    • B) To access superclass members
    • C) To override methods
    • D) To implement interfaces

    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.

  19. Question 19

    Q19. What is the purpose of a hash function?

    • A) To compress data
    • B) To encrypt data
    • C) To map data to a fixed-size index
    • D) To sort data

    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.

  20. Question 20

    Q20. What is the purpose of the 'this' keyword in Java?

    • A) To access superclass members
    • B) To access subclass members
    • C) To refer to the current object
    • D) To implement interfaces

    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.

1/20
0
0
Level 1

What is the time complexity of Bubble Sort?