Computer — All MCQs
4795 questions available
Q2341.Which is the correct syntax to declare an array in JavaScript?
Correct Answer: B
In JavaScript, arrays are declared using square brackets [ ]. Each element inside the brackets is separated by a comma (or spaces in simplified options). Parentheses ( ), curly braces { }, and angle brackets < > are not used for arrays.
Q2342.For storing large volumes of unstructured data like logs or JSON, which NoSQL database is most suitable?
Correct Answer: B
MongoDB is a NoSQL document database that stores data in JSON-like documents. It is ideal for large volumes of unstructured or semi-structured data like logs. Unlike SQL databases (MySQL, Oracle, SQL Server), it does not require a fixed schema.
Q2343.If you want to migrate a PHP website to a modern PHP framework, which one is most commonly used?
Correct Answer: A
Laravel is a modern PHP framework for building web applications. It provides MVC architecture, routing, and built-in security features. React and Node.js are JavaScript-based, and Django is Python-based.
Q2344.Which of the following describes unsupervised learning?
Correct Answer: B
Unsupervised learning finds patterns or structures in data without labeled outputs. Common tasks include clustering and dimensionality reduction. Supervised learning uses labeled data, while reinforcement learning is based on rewards and penalties.
Q2345.Which of the following is true about client-side vs server-side rendering?
Correct Answer: C
Client-side rendering (CSR) means the browser builds the page using JavaScript after receiving data. Server-side rendering (SSR) means the server sends a fully rendered HTML page to the browser. SSR improves SEO and initial page load speed.
Q2346.In networking, if a device can send data but never receives a reply, what type of issue is this?
Correct Answer: C
If a device can send data but never receives a reply, the problem is likely in the network path. Causes include network congestion, faulty routers, or incorrect routing tables. It is not necessarily a client-side or server-side problem if both are working correctly.
Q2347.What is a deadlock in multithreading?
Correct Answer: B
A deadlock occurs when two or more threads wait indefinitely for resources held by each other. None of the threads can proceed, causing the program to freeze. Proper resource management and lock ordering help prevent deadlocks.
Q2348.Analyze the following C++ program and determine its output: int x = 5; if (x > 3) x += 2; else x -= 2; cout << x;
Correct Answer: C
The initial value of x is 5. The if condition x > 3 is true. The statement x += 2 is executed, so x becomes 7. The else block is skipped, resulting in an output of 7.
Q2349.What is a mutex lock primarily used for in programming?
Correct Answer: B
A mutex (mutual exclusion) lock ensures that only one thread can access a shared resource at a time. It prevents race conditions, where multiple threads modify data simultaneously.
Q2350.Which Python library is best for numerical computation in ML?
Correct Answer: B
NumPy is a Python library for numerical computation and array operations. It provides fast mathematical functions for large datasets. Many machine learning libraries like TensorFlow and Scikit-learn use NumPy arrays internally.
Q2351.In a max-heap, if a node has index i (1-based indexing), what is the index of its parent?
Correct Answer: B
In a max-heap using 1-based indexing, the parent of a node at index i is at index i / 2. The left child of node i is at index 2 * i, and the right child is at index 2 * i + 1.
Q2352.If set A has 4 elements and set B has 4 elements, how many elements are in A x B?
Correct Answer: D
The Cartesian product means pairing every element of set A with every element of set B. Number of elements in A x B = (number of elements in A) * (number of elements in B). So, 4 * 4 = 16.
Q2353.Which statement best describes a transitive relation?
Correct Answer: A
A transitive relation means that if a relation holds between A and B, and B and C, it also holds between A and C. Example: "greater than" (>) is transitive: if A > B and B > C, then A > C.
Q2354.What will be the output of the following C++ code? bool b = false; cout << b + 2;
Correct Answer: C
In C++, false is evaluated as 0 in arithmetic operations. Therefore, b + 2 becomes 0 + 2 = 2.
Q2355.What is the output of the following C++ code? int a = 1, b = 0; cout << (a || a && b);
Correct Answer: B
&& has higher precedence than ||. a && b evaluates first, which gives 0 (since b is 0). Then, a || 0 is evaluated, which gives 1 (since a is 1). The final output is 1.
Q2356.What is the time complexity of a loop inside a loop, each running n times?
Correct Answer: C
A loop inside another loop is called a nested loop. If both loops run n times, the inner loop runs n times for each iteration of the outer loop. Total iterations = n * n = n^2, giving a time complexity of O(n^2).
Q2357.In data structures, what does unshift do?
Correct Answer: A
In arrays or lists, unshift adds a new element to the start of the structure. The existing elements are shifted one position to the right to make space.
Q2358.In data structures, what does shift do?
Correct Answer: A
In arrays or lists, shift removes the first element. The remaining elements are shifted one position to the left to fill the gap.
Q2359.In data structures, what does push do?
Correct Answer: B
In stack or list data structures, push is used to add an element to the top of the stack or the end of the structure.
Q2360.In data structures, what does pop do?
Correct Answer: B
In a stack, pop removes the element from the top (the last element added). Stacks follow the LIFO (Last In, First Out) principle.