Time 2

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

What is the output of the following C code?

c
Copy code
int x = 5;
printf("%d", x++);

1.
○ a) 4
○ b) 5
○ c) 6
○ d) Compilation Error
Answer: b) 5
2. What is the size of an int in C?
○ a) 2 bytes
○ b) 4 bytes
○ c) Depends on the platform
○ d) 8 bytes
Answer: c) Depends on the platform
3. Which of the following is a valid declaration of a pointer?
○ a) int *ptr;
○ b) int ptr*;
○ c) *int ptr;
○ d) None of the above
Answer: a) int *ptr;
4. Which sorting algorithm is the fastest in the average case?
○ a) Bubble Sort
○ b) Quick Sort
○ c) Merge Sort
○ d) Insertion Sort
Answer: b) Quick Sort
5. What is the time complexity of searching an element in a Binary Search Tree
(BST) in the worst case?
○ a) O(log n)
○ b) O(n)
○ c) O(n log n)
○ d) O(1)
Answer: b) O(n)

What is the output of the following Python code?


python
Copy code
list = [1, 2, 3]
print(list[1:2])

6.
○ a) [1, 2]
○ b) [1]
○ c) [2]
○ d) [2, 3]
Answer: c) [2]

Data Structures

7. What is the time complexity of inserting an element at the end of an array


(without resizing)?
○ a) O(n)
○ b) O(log n)
○ c) O(1)
○ d) O(n log n)
Answer: c) O(1)
8. Which data structure uses a First In First Out (FIFO) approach?
○ a) Stack
○ b) Queue
○ c) Array
○ d) Linked List
Answer: b) Queue
9. What is the time complexity of removing an element from the head of a singly
linked list?
○ a) O(n)
○ b) O(log n)
○ c) O(1)
○ d) O(n^2)
Answer: c) O(1)
10. Which of the following data structures allows efficient O(1) average time
complexity for insertion and deletion?
○ a) Stack
○ b) Queue
○ c) Hash Table
○ d) Binary Tree
Answer: c) Hash Table
11. In which scenario does the time complexity of binary search degrade to O(n)?
○ a) Sorted array
○ b) Unsorted array
○ c) Binary search never degrades
○ d) Linked list
Answer: d) Linked list

Object-Oriented Programming (OOP)

12. Which of the following is not a property of OOP?


○ a) Encapsulation
○ b) Inheritance
○ c) Polymorphism
○ d) Compilation
Answer: d) Compilation
13. What is it called when an object has multiple forms (such as a class having
multiple methods with the same name but different arguments)?
○ a) Encapsulation
○ b) Abstraction
○ c) Inheritance
○ d) Polymorphism
Answer: d) Polymorphism
14. Which OOP principle focuses on hiding internal details of objects and
exposing only what’s necessary?
○ a) Encapsulation
○ b) Inheritance
○ c) Abstraction
○ d) Polymorphism
Answer: a) Encapsulation
15. Which of the following is a feature of abstraction in OOP?
○ a) Providing implementation details
○ b) Hiding unnecessary details
○ c) Inheritance
○ d) Memory management
Answer: b) Hiding unnecessary details

Database Management Systems (DBMS)

16. Which of the following SQL clauses is used to fetch unique records from a
table?
○ a) SELECT DISTINCT
○ b) SELECT UNIQUE
○ c) SELECT PRIMARY
○ d) SELECT DIFFERENT
Answer: a) SELECT DISTINCT
17. What is the purpose of the JOIN operation in SQL?
○ a) To combine rows from two or more tables
○ b) To delete records
○ c) To filter records
○ d) To update records
Answer: a) To combine rows from two or more tables
18. What is the primary key used for in a database?
○ a) To store large data types
○ b) To uniquely identify each record
○ c) To relate two tables
○ d) To store sequential data
Answer: b) To uniquely identify each record
What is the output of the following SQL query?
sql
Copy code
SELECT COUNT(*) FROM Employees WHERE age > 30;

19.
○ a) A list of employees with age greater than 30
○ b) The count of employees with age greater than 30
○ c) Employees sorted by age
○ d) None of the above
Answer: b) The count of employees with age greater than 30
20. Which normal form eliminates partial dependency?
○ a) First Normal Form (1NF)
○ b) Second Normal Form (2NF)
○ c) Third Normal Form (3NF)
○ d) Boyce-Codd Normal Form (BCNF)
Answer: b) Second Normal Form (2NF)

Operating Systems

21. What is a deadlock in an operating system?


○ a) A process terminates unexpectedly
○ b) Multiple processes wait for each other to release resources
○ c) A process completes its execution
○ d) None of the above
Answer: b) Multiple processes wait for each other to release resources
22. Which of the following scheduling algorithms is non-preemptive?
○ a) Round Robin
○ b) First-Come-First-Served (FCFS)
○ c) Shortest Remaining Time First
○ d) Multilevel Queue
Answer: b) First-Come-First-Served (FCFS)
23. What is the role of the memory management unit (MMU)?
○ a) Manages process scheduling
○ b) Translates logical addresses to physical addresses
○ c) Manages files on the disk
○ d) Allocates CPU to processes
Answer: b) Translates logical addresses to physical addresses

Networking

24. What does TCP stand for?


○ a) Transfer Communication Protocol
○ b) Transmission Control Protocol
○ c) Transmission Common Protocol
○ d) None of the above
Answer: b) Transmission Control Protocol
25. In the OSI model, which layer is responsible for routing?
○ a) Physical layer
○ b) Data link layer
○ c) Network layer
○ d) Transport layer
Answer: c) Network layer

Cloud Computing

26. Which of the following is not a type of cloud service model?


○ a) IaaS
○ b) PaaS
○ c) SaaS
○ d) FaaS
Answer: d) FaaS
27. What is the benefit of using cloud computing?
○ a) Cost reduction
○ b) Scalability
○ c) Resource optimization
○ d) All of the above
Answer: d) All of the above
28. Which of the following is a cloud platform?
○ a) Google Cloud
○ b) Oracle
○ c) Facebook
○ d) Netflix
Answer: a) Google Cloud

29. What is the output of the following C++ code?


cpp
Copy code
int a = 5, b = 10;
a = a + b - (b = a);
cout << a << " " << b;

● a) 5 10
● b) 10 5
● c) 0 10
● d) 15 5
Answer: d) 15 5

30. In Java, which of the following is a correct way to declare a 2D array?

● a) int[][] arr = new int[10][10];


● b) int[10][10] arr;
● c) int arr[][] = new int[10][];
● d) int arr[10][] = new int[][10];
Answer: a) int[][] arr = new int[10][10];

31. Which of the following is an advantage of a doubly linked list over a


singly linked list?

● a) Easier deletion of nodes


● b) Requires less memory
● c) Faster access to middle elements
● d) None of the above
Answer: a) Easier deletion of nodes

32. Which data structure is used in recursion?

● a) Stack
● b) Queue
● c) Array
● d) Linked List
Answer: a) Stack

33. Which of the following is a disadvantage of a linked list?

● a) Memory is wasted due to the use of pointers


● b) Insertion and deletion operations are slow
● c) Access to elements is slow
● d) Both b and c
Answer: c) Access to elements is slow

34. What is the space complexity of merge sort?


● a) O(1)
● b) O(n log n)
● c) O(log n)
● d) O(n)
Answer: d) O(n)

35. In Python, what will the following code output?


python
Copy code
x = [1, 2, 3, 4, 5]
print(x[1:4])

● a) [1, 2, 3]
● b) [2, 3, 4]
● c) [2, 3]
● d) [3, 4, 5]
Answer: b) [2, 3, 4]

36. Which of the following methods is used to allocate memory


dynamically in C++?

● a) malloc()
● b) new
● c) calloc()
● d) realloc()
Answer: b) new

37. In which case does the worst-case scenario of Quick Sort occur?

● a) When the pivot is the smallest element


● b) When the pivot is the largest element
● c) When the array is already sorted
● d) Both a and b
Answer: d) Both a and b

38. What is the advantage of AVL trees over binary search trees (BST)?

● a) AVL trees are more balanced, ensuring O(log n) operations


● b) AVL trees are faster than BST for all operations
● c) AVL trees use less memory than BST
● d) None of the above
Answer: a) AVL trees are more balanced, ensuring O(log n) operations

39. What is a dangling pointer in C?

● a) A pointer that is not initialized


● b) A pointer that points to a freed memory location
● c) A pointer that points to another pointer
● d) A pointer that points to a null value
Answer: b) A pointer that points to a freed memory location

40. What is the time complexity of inserting an element in a Max Heap?

● a) O(n)
● b) O(log n)
● c) O(n log n)
● d) O(1)
Answer: b) O(log n)

41. In SQL, which of the following commands is used to update records


in a table?

● a) UPDATE
● b) MODIFY
● c) CHANGE
● d) INSERT
Answer: a) UPDATE

42. What is the ACID property in databases?

● a) Atomicity, Consistency, Isolation, Durability


● b) Availability, Consistency, Isolation, Durability
● c) Atomicity, Currency, Isolation, Durability
● d) Availability, Currency, Isolation, Durability
Answer: a) Atomicity, Consistency, Isolation, Durability
43. Which scheduling algorithm allocates the CPU to the process that
arrives first?

● a) Round Robin
● b) Shortest Job First
● c) First-Come-First-Served (FCFS)
● d) Priority Scheduling
Answer: c) First-Come-First-Served (FCFS)

44. Which layer of the OSI model ensures reliable communication?

● a) Physical Layer
● b) Data Link Layer
● c) Network Layer
● d) Transport Layer
Answer: d) Transport Layer

45. What is the maximum number of children that a binary tree node can
have?

● a) 1
● b) 2
● c) 3
● d) 4
Answer: b) 2

46. Which of the following is not a cloud deployment model?

● a) Public Cloud
● b) Private Cloud
● c) Hybrid Cloud
● d) Managed Cloud
Answer: d) Managed Cloud

47. Which of the following is a benefit of cloud computing?

● a) Cost efficiency
● b) Scalability
● c) Accessibility
● d) All of the above
Answer: d) All of the above

48. Which of the following is a type of NoSQL database?

● a) Relational Database
● b) Column-family Store
● c) XML Database
● d) SQL Database
Answer: b) Column-family Store

49. What does DNS stand for in networking?

● a) Domain Number System


● b) Domain Name Server
● c) Domain Name System
● d) Data Name System
Answer: c) Domain Name System

50. In cloud computing, what does “SaaS” stand for?

● a) Software as a System
● b) Software and Application Services
● c) Software as a Service
● d) System as a Service
Answer: c) Software as a Service

You might also like