1. Home
  2. MCQs by exam
  3. PPSC IT

PPSC IT MCQs · Page 9

577 multiple choice questions typical of the PPSC IT exam, with answers and explanations. Switch on practice mode to test yourself first.

Showing 201–225 of 577

Which predicate on an indexed order_date column can use a B-tree index?

  1. CAST(order_date AS TEXT) LIKE '2024%', which cannot use the index
  2. order_date + INTERVAL '1 day' = '2024-06-01', a computed date
  3. order_date >= '2024-01-01' AND order_date < '2025-01-01' Correct answer
  4. EXTRACT(YEAR FROM order_date) = 2024, which scans every row
MCQSEXAM Read explanation

Which statement about TRUNCATE compared with DELETE is correct?

  1. TRUNCATE accepts a WHERE clause but is slower than DELETE, because it scans the whole table row by row
  2. Both fire row-level triggers once per removed row, so auditing behaves exactly the same for the two statements here
  3. DELETE cannot be rolled back in any database, while TRUNCATE always can, because it is DDL and not DML
  4. TRUNCATE removes all rows in one operation, cannot take a WHERE clause and fires no row-level delete triggers Correct answer
MCQSEXAM Read explanation

What does LAG(sales, 1, 0) OVER (PARTITION BY store ORDER BY month) return?

  1. The store's average sales, with 0 substituted wherever the partition is empty or has one row
  2. The next month's sales within the same store, with 0 substituted for the last row of each partition
  3. The running total of sales within each store, starting at 0 at the very first row of every partition here
  4. The previous month's sales within the same store, with 0 substituted for the first row of each partition Correct answer
MCQSEXAM Read explanation

Why can WHERE x NOT IN (SELECT y FROM t) return no rows when the subquery yields a NULL?

  1. Because NOT IN converts the NULL to zero and then compares numerically, matching every zero value
  2. Because x <> NULL is UNKNOWN, so the NOT IN predicate can never be TRUE; NOT EXISTS is null-safe Correct answer
  3. Because the subquery is executed only when it contains no NULL values, and otherwise the whole subquery is skipped
  4. Because NOT IN is not valid with a subquery at all, so the parser rejects the statement outright
MCQSEXAM Read explanation

Which statement contrasts UNION and UNION ALL correctly?

  1. UNION removes duplicate rows and therefore usually needs a sort or hash, while UNION ALL concatenates and keeps duplicates Correct answer
  2. Both remove duplicate rows, differing only in the column ordering they produce, so the choice between them is purely cosmetic
  3. UNION requires matching column names, while UNION ALL does not, which is why UNION ALL is faster to write
  4. UNION ALL removes duplicate rows, while UNION keeps them, so the two operators are exact opposites in effect
MCQSEXAM Read explanation

When GROUP BY runs on a column containing NULLs, how are those rows treated?

  1. The rows are excluded from the result entirely, because the grouping key is missing
  2. The query fails unless NULLs are filtered out first, since grouping needs a known key
  3. All NULLs form a single group, because GROUP BY treats them as equal to each other Correct answer
  4. Each NULL forms its own separate group, because NULL is never equal to another one
MCQSEXAM Read explanation

Counting customers by joining customers to orders and using COUNT(*) inflates the number. Why, and what fixes it?

  1. Because COUNT(*) ignores NULLs in the customer key, so rows with a missing key are never counted at all by the aggregate
  2. The one-to-many join repeats each customer row per order, so COUNT(DISTINCT customer_id) or a subquery gives the true count Correct answer
  3. Because the join sorts the rows and duplicates them during the sort, so the sort key must therefore be made distinct first of all
  4. Because COUNT(*) counts columns rather than rows, so it returns the width of the joined result instead of its height
MCQSEXAM Read explanation

A LEFT JOIN carries the right-table condition b.status = 'active' in the WHERE clause instead of the ON clause. What is the effect?

  1. Nothing changes, because the optimiser moves the predicate into the ON clause
  2. All inactive matches are kept while unmatched rows are duplicated
  3. The query fails because WHERE cannot reference the right table
  4. Rows with no matching b row are removed, turning the outer join into an effective inner join Correct answer
MCQSEXAM Read explanation

Values 100, 100, 90 are ranked in descending order. What do RANK, DENSE_RANK and ROW_NUMBER produce?

  1. 1,2,3 for all three functions, because every row receives a distinct sequential position
  2. 1,1,2 for RANK and 1,1,3 for DENSE_RANK, with 1,2,3 for ROW_NUMBER in the very same single query
  3. 1,1,3 for RANK; 1,1,2 for DENSE_RANK; and 1,2,3 for ROW_NUMBER with an arbitrary tie order Correct answer
  4. 1,1,3 for all three, since ties always skip a position whatever function is used
MCQSEXAM Read explanation

In SUM(x) OVER (ORDER BY d), the default window frame uses RANGE. What practical difference does that make compared with an explicit ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW?

  1. RANGE requires a PARTITION BY clause, whereas ROWS can be used over the whole table without one
  2. ROWS ignores the ORDER BY, whereas RANGE sorts the partition before summing
  3. Rows that tie on d are all included in the same running total under RANGE, while ROWS admits them one at a time Correct answer
  4. RANGE includes only the current row, whereas ROWS accumulates every preceding row in the partition
MCQSEXAM Read explanation

Which curve would you inspect to decide whether collecting more training data is likely to help?

  1. The precision-recall curve, which plots precision against recall at every threshold
  2. The validation curve, which plots scores against one hyperparameter value at a time
  3. The ROC curve, which plots the true positive rate against the false positive rate of the model
  4. The learning curve, which plots training and validation scores against training-set size Correct answer
MCQSEXAM Read explanation

What does passing sample_weight to fit() actually do?

  1. It multiplies each row's contribution to the loss by its weight, without resampling the data Correct answer
  2. It sorts the rows so that heavier samples are fitted first and influence the coefficients more
  3. It affects only predict, not the fitted coefficients, which are always learned unweighted
  4. It physically replicates rows in proportion to their weights before the fit begins to run
MCQSEXAM Read explanation

RandomForestClassifier(oob_score=True) requires which condition to produce a meaningful out-of-bag score?

  1. max_features must equal the total number of features, so that every split always sees the whole feature set
  2. The number of trees must be less than the number of samples, so that every tree sees fresh data
  3. criterion must be set to entropy, because the Gini criterion cannot track the out-of-bag error
  4. bootstrap=True, since out-of-bag samples exist only when each tree is trained on a bootstrap resample Correct answer
MCQSEXAM Read explanation

How does predict_proba differ from decision_function?

  1. predict_proba returns normalised class probabilities summing to one, while decision_function returns unbounded signed distances to the decision boundary Correct answer
  2. decision_function returns probabilities between zero and one, while predict_proba returns raw margins, so the two names are swapped in most of the documentation
  3. Both return probabilities, but predict_proba is only for regressors while decision_function is only for classifiers, so neither applies here
  4. predict_proba is available on every estimator, while decision_function is not, which is why predict_proba is the preferred interface for scoring
MCQSEXAM Read explanation

A modeller runs cross_val_predict(model, X, y, cv=5) and then computes accuracy on the returned predictions in order to select hyperparameters. What is the main objection?

  1. It requires a separate hold-out set and raises NotFittedError when none is supplied alongside cv
  2. The predictions are out-of-fold, but the same folds would also drive selection, so the resulting score is not a clean estimate Correct answer
  3. cross_val_predict refits on the full dataset first, so every prediction is in-sample and therefore over-optimistic
  4. It returns one aggregate score per fold instead of predictions, so accuracy cannot be computed from its output
MCQSEXAM Read explanation

Why would you construct StandardScaler(with_mean=False)?

  1. Because without centring the transformed features are always positive and therefore easier to interpret
  2. Because with_mean=False switches to median and interquartile scaling instead of the ordinary mean
  3. Centring would densify a sparse matrix, so scaling by the standard deviation alone preserves sparsity Correct answer
  4. Sparse matrices cannot be divided by a scalar, so only centring is available for them in practice
MCQSEXAM Read explanation

What does train_test_split(X, y, stratify=y) guarantee?

  1. The training and test sets keep approximately the same class proportions as the full dataset Correct answer
  2. Only samples with non-missing labels are used, and rows with NaN labels are dropped
  3. Each class appears exactly once in the test set, regardless of how many samples it has
  4. The split is reproducible without setting random_state, because stratification fixes the seed
MCQSEXAM Read explanation

Why does putting StandardScaler and a classifier inside Pipeline prevent leakage during cross_val_score?

  1. Pipeline refits the scaler on every validation fold to check stability across the splits
  2. The pipeline scales the whole dataset once before splitting, which is equivalent and faster
  3. During each fold, fit runs on the training part only and transform is applied to the held-out part Correct answer
  4. Pipeline disables scaling during cross-validation entirely, so the scaler only runs on the final fit
MCQSEXAM Read explanation