UST interview prep
18 practice questions on the topics candidates reported from UST interviews, with answers. The questions are ours; each one links to the interview report that names its topic.
DSA 3
-
What is the length of the longest common subsequence of "STONE" and "LONGEST"?
- 2
- 3
- 4
- 5
Show the answer
B. 3
dp[i][j] is the answer for the first i letters of one word and the first j of the other: equal letters give dp[i-1][j-1] + 1, otherwise the larger of dp[i-1][j] and dp[i][j-1]. "ONE" appears in order in both words. O(mn) time.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
-
Merge sort splits the array in half, sorts each half and merges them. What is its time complexity, and its extra space for an array?
- O(n log n) time in every case, with O(n) extra space for merging
- O(n^2) time in the worst case, with O(1) extra space
- O(n) time, with O(log n) extra space
- O(n log n) time on average but O(n^2) in the worst case
Show the answer
A. O(n log n) time in every case, with O(n) extra space for merging
There are log n levels of halving and each level merges n elements, whatever the input order. Merging needs a temporary array. Quick sort is the one that degrades to O(n^2).
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
-
Which of these runs in O(log n) time on n items?
- Binary search for a key in a sorted array
- Finding the largest value in an unsorted array
- Comparing every pair of elements
- Printing every element
Show the answer
A. Binary search for a key in a sorted array
Binary search halves what is left on every step, so it needs about log2 n steps: 20 steps for a million items. A scan of every element is O(n), and comparing every pair is O(n^2). n is the size of the input.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
Java 3
-
How are the JDK, the JRE and the JVM related?
- The JDK contains the JRE plus tools such as javac; the JRE contains the JVM plus the standard libraries; the JVM runs bytecode
- The JVM contains the JDK
- The JRE is needed to compile Java, the JDK to run it
- They are three names for the same program
Show the answer
A. The JDK contains the JRE plus tools such as javac; the JRE contains the JVM plus the standard libraries; the JVM runs bytecode
You compile with the JDK's javac to bytecode; the JVM inside the JRE runs that bytecode. Recent Java versions ship the JDK (or a jlink-built runtime) rather than a separate JRE download.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
-
In Java, can you create an object of a static class?
- No, static classes can never be instantiated
- Yes, any top-level class can be declared static
- Only a nested class can be static, and yes: new Outer.Nested() works without any Outer object
- Only through reflection
Show the answer
C. Only a nested class can be static, and yes: new Outer.Nested() works without any Outer object
A top-level class cannot be static. A static nested class is just a class scoped inside another, with no hidden reference to an outer instance, so it is created like any other class. An inner (non-static) class needs an outer object: outer.new Inner().
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
-
What does this print?
public class Main { public static void main(String[] args) { String a = "ust"; String b = "ust"; String c = new String("ust"); System.out.println((a == b) + " " + (a == c) + " " + a.equals(c)); } }- true true true
- true false false
- false false true
- true false true
Show the answer
D. true false true
String literals are interned in the String pool, so a and b are the same object. new String always makes a new object outside the pool, so a == c is false. equals compares the characters, so it is true. c.intern() would return the pooled one.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
OOP 1
-
Which kind of inheritance does Java not allow between classes?
- Single inheritance
- Hierarchical inheritance
- Multilevel inheritance
- Multiple inheritance: a class can extend only one class, though it can implement many interfaces
Show the answer
D. Multiple inheritance: a class can extend only one class, though it can implement many interfaces
Extending two classes would raise the diamond problem: which parent's fields and method win. Java allows one superclass and any number of interfaces; since Java 8, a clash between two default methods must be resolved in the class.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
DBMS and SQL 6
-
What does adding an index on a column usually do?
- Speeds up queries that search or sort on that column, at the cost of extra storage and slower inserts and updates
- Speeds up every query on the table, with no cost
- Prevents duplicate values in the column
- Compresses the table to save space
Show the answer
A. Speeds up queries that search or sort on that column, at the cost of extra storage and slower inserts and updates
A B-tree index lets the database find matching rows in O(log n) instead of scanning the table. Every write must also update the index, so indexes go on columns that are searched often. Only a UNIQUE index stops duplicates.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
-
What is a trigger in SQL?
- A query that runs on a schedule, such as every night
- Code the database runs automatically when a chosen event, such as an INSERT, UPDATE or DELETE on a table, happens
- A constraint that stops NULL values
- Another name for a stored procedure the user calls by hand
Show the answer
B. Code the database runs automatically when a chosen event, such as an INSERT, UPDATE or DELETE on a table, happens
A trigger can run BEFORE or AFTER the event, for example to write an audit row whenever a salary changes. A stored procedure, by contrast, runs only when it is called.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
-
emp has rows (1, Asha, NULL), (2, Ravi, 1), (3, Meena, 1) as (id, name, manager_id). How many rows does this return?
SELECT e.name, m.name AS manager FROM emp e JOIN emp m ON e.manager_id = m.id;- 3
- 1
- 2
- 0
Show the answer
C. 2
A self join joins a table to itself under two aliases. Ravi and Meena each match Asha as manager; Asha has no manager, so the inner join drops her. A LEFT JOIN would keep her with a NULL manager, giving 3.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
-
A students table has a skills column holding values like "Python, SQL, Java". Which normal form does that break, and what is the fix?
- BCNF; split the table by primary key
- None; text columns may hold lists
- Third normal form; add an index on skills
- First normal form, which needs atomic values; move skills to a separate table with one row per student and skill
Show the answer
D. First normal form, which needs atomic values; move skills to a separate table with one row per student and skill
1NF wants one value per cell. With a list in a cell you cannot index, join or count skills cleanly, and "find every SQL student" needs string matching. A student_skills table, keyed on (student_id, skill), fixes it.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
-
Why is a DBMS preferred over keeping data in plain files?
- It gives concurrent access with transactions, constraints that keep data consistent, indexes and a query language, and recovery after a crash
- Files cannot hold text
- A DBMS always uses less disk space
- Files cannot be backed up
Show the answer
A. It gives concurrent access with transactions, constraints that keep data consistent, indexes and a query language, and recovery after a crash
With plain files every program has to handle locking, duplicates, partial writes and searching by itself. A DBMS does that once: ACID transactions, keys and constraints, indexed queries in SQL, and logs to recover.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
-
What is a stored procedure?
- A backup of a table
- A query the database runs automatically when a row changes
- A named block of SQL saved in the database, run with a call and able to take parameters
- An index on a view
Show the answer
C. A named block of SQL saved in the database, run with a call and able to take parameters
A procedure runs where the data is, so a multi-step job costs one round trip, and access can be granted to the procedure rather than the tables. A trigger is the one that runs automatically on an INSERT, UPDATE or DELETE.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
Operating systems 1
-
What is the key difference between two processes and two threads of one process?
- Processes have separate address spaces; threads of one process share memory
- Threads cannot run at the same time
- Processes share memory; threads do not
- Threads each need their own copy of the program code
Show the answer
A. Processes have separate address spaces; threads of one process share memory
Threads share the process's heap, globals and open files, so they communicate cheaply but need locks. Processes are isolated, so one crashing does not take the other down, and they talk through pipes, sockets or shared memory.
This topic is named in a candidate’s interview report: Software engineer on-campus interview, Pune, 2023, on GeeksforGeeks.
Computer networks 1
-
Which HTTP method is NOT idempotent?
- GET
- PUT
- DELETE
- POST
Show the answer
D. POST
Repeating a PUT or DELETE leaves the server in the same state, but repeating a POST can create a second order. That is why payment APIs add idempotency keys.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
Web development 2
-
MongoDB stores documents as BSON rather than plain JSON text. What does BSON add?
- Nothing: it is JSON with a different file extension
- Encryption of every field
- A binary encoding with lengths up front and extra types such as dates, 64-bit integers, binary data and ObjectId
- A schema the database enforces on every document
Show the answer
C. A binary encoding with lengths up front and extra types such as dates, 64-bit integers, binary data and ObjectId
Length prefixes let MongoDB skip over fields without parsing them, and the extra types survive a round trip that JSON would turn into strings. It is not always smaller than JSON. Drivers convert to and from JSON for you.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
-
What does this print?
var a = 2; a = "ust"; console.log(typeof a, a);- number 2
- number ust
- It throws a TypeError
- string ust
Show the answer
D. string ust
JavaScript is dynamically typed: the variable has no fixed type, the value does. Reassigning a string is allowed. Only const forbids reassignment, and that would throw a TypeError whatever the new value's type.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.
Software engineering 1
-
What is the difference between Git and GitHub?
- Git is the version control tool that runs on your machine; GitHub is a service that hosts Git repositories and adds pull requests, issues and CI
- They are the same product
- GitHub is the command line, Git is the website
- Git only works with GitHub
Show the answer
A. Git is the version control tool that runs on your machine; GitHub is a service that hosts Git repositories and adds pull requests, issues and CI
Git keeps the full history locally and works with no network. GitHub, like GitLab or Bitbucket, is one place to push a copy so a team can share it and review changes.
This topic is named in a candidate’s interview report: Software engineer full-time interview, 2024, on GeeksforGeeks.