Showing 221–240 of 603

Q221.Determine the output of the following? JavaScript code: console.log(false == 0) console.log(false === 0)

Easy
A true, true
B false, false
C true, false
D false, true
Programming Basics PPSC

Correct Answer: C

console.log(false == 0) prints true because '==' performs type coercion, and false coerces to 0, so 0 == 0 is true. console.log(false === 0) prints false because '===' checks both value and type, and a boolean is never strictly equal to a number.

Q222.A variable starts at 0 and is incremented by +2 each time. It should not exceed 10. How many iterations are required?

Easy
A 4
B 5
C 6
D 10
Programming Basics PPSC

Correct Answer: B

Start value = 0. Increment by +2 each time. Iterations: 1 -> 2; 2 -> 4; 3 -> 6; 4 -> 8; 5 -> 10. After 5 iterations, value reaches 10 (limit). It should not exceed 10, so we stop here. Total iterations = 5.

Q223.Which loop is used to retrieve the first true condition and then stops?

Easy
A for loop
B while loop
C do-while loop
D if statement
Programming Basics PPSC

Correct Answer: D

An if statement checks a condition and executes once if it is true. It does not loop repeatedly, unlike for, while, or do-while loops. It effectively stops after the first true condition is evaluated.

Q224.Given syntax is correct but output/error shows "video can't be played". Likely cause?

Easy
A Browser does not support the video format
B Code syntax error
C Operating system issue
D Video file missing
Programming Basics PPSC

Correct Answer: A

The syntax is already correct, so the issue is not in the code. Browsers support only certain formats like MP4, WebM, or OGG.

Q225.Snippet: System.out.println("Hello World")?

Easy
A C++
B Python
C Java
D JavaScript
Programming Basics PPSC

Correct Answer: C

System.out.println() is a Java statement used to print output to the console. C++ uses cout << "Hello World";. Python uses print("Hello World"). JavaScript uses console.log("Hello World");. This syntax is specific to Java's standard output system.

Q226.Which program/code corresponds to Pandas library in Python?

Easy
A import pandas as pd
B import numpy as np
C import matplotlib.pyplot as plt
D import sklearn as sk
Programming Basics PPSC

Correct Answer: A

Pandas is a Python library for data manipulation and analysis. The standard import statement is: import pandas as pd. NumPy is for numerical computations, Matplotlib is for data visualization, and Scikit-learn is for machine learning.

Q227.Which is the correct syntax to declare an array in JavaScript?

Easy
A var arr = (1 2 3);
B var arr = [1 2 3];
C var arr = {1 2 3};
D var arr = <1 2 3>;
Programming Basics PPSC

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.

Q228.For storing large volumes of unstructured data like logs or JSON, which NoSQL database is most suitable?

Easy
A MySQL
B MongoDB
C Oracle
D SQL Server
Database Basics PPSC

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.

Q229.Analyze the following C++ program and determine its output: int x = 5; if (x > 3) x += 2; else x -= 2; cout << x;

Easy
A 3
B 5
C 7
D 2
Programming Basics PPSC

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.

Q230.Which Python library is best for numerical computation in ML?

Easy
A Matplotlib
B NumPy
C Seaborn
D Scikit-learn
Programming Basics PPSC

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.

Q231.What will be the output of the following C++ code? bool b = false; cout << b + 2;

Easy
A 0
B 1
C 2
D 3
Programming Basics PPSC

Correct Answer: C

In C++, false is evaluated as 0 in arithmetic operations. Therefore, b + 2 becomes 0 + 2 = 2.

Q232.What is the output of the following C++ code? int a = 1, b = 0; cout << (a || a && b);

Easy
A 0
B 1
C Error
D Undefined
Programming Basics PPSC

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.

Q233.What is the time complexity of a loop inside a loop, each running n times?

Easy
A O(n)
B O(log n)
C O(n^2)
D O(n log n)
Programming Basics PPSC

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).

Q234.In data structures, what does unshift do?

Easy
A Adds an element to the beginning
B Removes the last element
C Removes the first element
D Adds an element to the end
Programming Basics PPSC

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.

Q235.In data structures, what does shift do?

Easy
A Removes the first element
B Adds an element to the end
C Removes the last element
D Adds an element to the beginning
Programming Basics PPSC

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.

Q236.In data structures, what does push do?

Easy
A Removes the first element
B Adds an element to the end
C Removes the last element
D Adds an element to the beginning
Programming Basics PPSC

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.

Q237.In data structures, what does pop do?

Easy
A Adds an element to the beginning
B Removes the last element
C Removes the first element
D Adds an element to the end
Programming Basics PPSC

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.

Q238.Which command is used to list all files and directories in Linux?

Easy
A ls
B cd
C mkdir
D rm
Operating Systems PPSC

Correct Answer: A

The ls command in Linux is used to list all files and directories in the current directory. cd changes directories, mkdir creates a directory, and rm deletes files.

Q239.Which sign/algorithm uses a "time quantum" to allocate CPU time to processes?

Easy
A Priority Scheduling
B Round Robin (RR)
C Shortest Job First (SJF)
D None of these
Programming Basics PPSC

Correct Answer: B

Round Robin (RR) is a CPU scheduling algorithm that assigns each process a fixed time slice called a time quantum. It is a preemptive scheduling algorithm.

Q240.Which of the following is the Average Case Time Complexity fo the Bubble sort algorithm?

Easy
A O(n^2)
B O(n)
C O^2(n)
D None of these
Programming Basics PPSC

Correct Answer: A

Bubble Sort has an average and worst-case time complexity of O(n^2) due to nested passes over the array.