The 2025 advertisement names these styles for Phase II Paper 2: logic flow completion, debugging, syntax understanding, program dry-run outputs and data analysis, “etc.” We use the same names on the Phase I code questions. “Query output”, “Calculation” and “Concept” are our own labels. Try each question before you read the green box.
Under the 2025 advertisement, Phase I Paper 2 was 50 questions in 40 minutes, so about 48 seconds each on average.
TVK practice question, not from a SEBI paper
Sample 1: Programming Concepts (Java / C / C++)
Phase I topic. Style: Program dry-run output. Language: C.
What does this C program print?
#include <stdio.h>
int next_even(void) {
static int n = 0;
n = n + 2;
return n;
}
void update(int a, int *b) {
int t = a;
a = *b;
*b = t;
}
int main(void) {
int x = 3, y = 7;
update(x, &y);
next_even();
printf("%d %d %d\n", x, y, next_even());
return 0;
}
- A.3 7 2
- B.7 3 4
- C.3 3 4
- D.7 7 4
- E.3 3 2
Answer: C. 3 3 4
x is passed by value, so update changes only its own copy and x stays 3. b points to y, so *b = t sets y to 3. The static variable n keeps its value between calls: the first next_even() returns 2 and that result is dropped, and the second returns 4. Running it prints 3 3 4.
TVK practice question, not from a SEBI paper
Sample 2: Programming Concepts (Java / C / C++)
Phase I topic. Style: Program dry-run output. Language: Java.
What does this Java program print?
class Base {
String name = "base";
String who() { return "Base.who"; }
static String tag() { return "Base.tag"; }
}
class Child extends Base {
String name = "child";
@Override String who() { return "Child.who"; }
static String tag() { return "Child.tag"; }
}
public class Main {
public static void main(String[] args) {
Base b = new Child();
System.out.println(b.name + " " + b.who() + " " + b.tag());
}
}
- A.child Child.who Child.tag
- B.base Base.who Base.tag
- C.child Child.who Base.tag
- D.base Child.who Base.tag
- E.The program does not compile.
Answer: D. base Child.who Base.tag
The variable b has the declared type Base and holds a Child object. Fields and static methods are bound at compile time from the declared type, so b.name is base and b.tag() is Base.tag. Instance methods are bound at run time from the object, so b.who() runs the Child version. Running it prints base Child.who Base.tag.
TVK practice question, not from a SEBI paper
Sample 3: SQL Queries
Phase I topic. Style: Query output. Language: SQL.
What row does the SELECT return for HR?
CREATE TABLE dept (id INT, name TEXT);
CREATE TABLE emp (id INT, dept_id INT, salary INT);
INSERT INTO dept VALUES (1,'IT'), (2,'Legal'), (3,'HR');
INSERT INTO emp VALUES (10,1,50), (11,1,NULL), (12,2,40);
SELECT d.name, COUNT(*), COUNT(e.salary)
FROM dept d LEFT JOIN emp e ON e.dept_id = d.id
GROUP BY d.name
ORDER BY d.name;
- A.HR, 0, 0
- B.HR, 1, 0
- C.HR, 1, 1
- D.HR, 0, 1
- E.No row is returned for HR.
Answer: B. HR, 1, 0
HR has no employees, so the LEFT JOIN keeps one HR row with NULL in every emp column. COUNT(*) counts that row and gives 1. COUNT(e.salary) skips NULL and gives 0. Running it in SQLite prints HR|1|0, IT|2|1 and Legal|1|1.
TVK practice question, not from a SEBI paper
Sample 4: Data Analytics Languages (Python / R)
Phase I topic. Style: Data analysis. Language: Python.
What does this Python program print?
sales = [("asha", 70), ("ravi", 40), ("asha", 90),
("meena", 40), ("ravi", 60)]
totals = {}
for name, amount in sales:
totals[name] = totals.get(name, 0) + amount
top = sorted(totals, key=totals.get, reverse=True)[:2]
print(top, totals["ravi"])
- A.['meena', 'ravi'] 100
- B.[160, 100] 100
- C.['asha', 'meena'] 60
- D.['ravi', 'asha'] 40
- E.['asha', 'ravi'] 100
Answer: E. ['asha', 'ravi'] 100
The loop builds the totals asha 160, ravi 100 and meena 40. sorted over a dictionary returns its keys, here ordered by total from high to low, and [:2] keeps the first two. totals["ravi"] is 40 + 60 = 100. Running it prints ['asha', 'ravi'] 100.
TVK practice question, not from a SEBI paper
Sample 5: Networking Concepts
Phase I topic. Style: Calculation.
A host has the IPv4 address 192.168.10.130 with subnet mask 255.255.255.192. What are the network address of its subnet and the number of usable host addresses in that subnet?
- A.192.168.10.128 and 62
- B.192.168.10.128 and 64
- C.192.168.10.0 and 62
- D.192.168.10.192 and 62
- E.192.168.10.128 and 126
Answer: A. 192.168.10.128 and 62
Mask 255.255.255.192 is /26, so the last octet moves in blocks of 64: 0, 64, 128, 192. 130 falls in the block that starts at 128, and that block ends at the broadcast address 192.168.10.191. It holds 64 addresses. Take away the network and broadcast addresses and 62 are usable. Python's ipaddress module gives the same network and count.
TVK practice question, not from a SEBI paper
Sample 6: Information & Cyber Security
Phase I topic. Style: Concept.
A payroll clerk is allowed to read every salary in the HR database. A wrong permission setting also lets the clerk change a colleague's salary figure, and the clerk does so. The database stays online, and nobody sees data they were not already allowed to see. Which property of the CIA triad was broken?
- A.Confidentiality
- B.Integrity
- C.Availability
- D.Confidentiality and availability together
- E.None of the three
Answer: B. Integrity
Integrity means data changes only in allowed ways. The clerk was only meant to read salaries, so the changed figure breaks integrity. Confidentiality is untouched, because the clerk could already see these figures and nobody else saw anything new. Availability is untouched, because the database stayed online.
Under the 2025 advertisement, Phase II Paper 2 was 100 questions in 180 minutes, so about 108 seconds each on average. See the Phase II preparation guide for how to prepare for this paper.
TVK practice question, not from a SEBI paper
Sample 7: Data Structure
Phase II topic. Style: Logic flow completion. Language: C.
The list starts as 1, 2, 3, 4. Which statement, placed at the missing line, makes this C program print 4 3 2 1?
#include <stdio.h>
#include <stdlib.h>
struct Node { int val; struct Node *next; };
struct Node *push(struct Node *head, int val) {
struct Node *n = malloc(sizeof *n);
n->val = val;
n->next = head;
return n;
}
struct Node *reverse(struct Node *head) {
struct Node *prev = NULL, *cur = head, *after;
while (cur != NULL) {
after = cur->next;
/* MISSING LINE */
prev = cur;
cur = after;
}
return prev;
}
int main(void) {
struct Node *head = NULL;
for (int v = 4; v >= 1; v--) head = push(head, v);
head = reverse(head);
for (; head != NULL; head = head->next)
printf("%d ", head->val);
printf("\n");
return 0;
}
- A.cur->next = after;
- B.prev->next = cur;
- C.after->next = cur;
- D.cur->next = prev;
- E.cur = prev;
Answer: D. cur->next = prev;
Each node must end up pointing back at the node before it, and prev holds that node. after has already saved the rest of the list, so overwriting cur->next loses nothing. We ran all five options in this slot. cur->next = prev; printed 4 3 2 1. cur->next = after; printed only 4, because no link changes and prev ends on the last node. prev->next = cur; crashed on the first pass, because prev is still NULL. after->next = cur; never finished, because it ties nodes 1 and 2 into a loop. cur = prev; printed an empty line, because the function returns NULL.
TVK practice question, not from a SEBI paper
Sample 8: Data Structure
Phase II topic. Style: Data analysis. Language: Python.
What does this Python program print?
import json
raw = """[
{"dept": "IT", "skills": ["c", "java"], "exp": {"yrs": 4}},
{"dept": "HR", "skills": [], "exp": {"yrs": 7}},
{"dept": "IT", "skills": ["python"], "exp": {"yrs": 2}},
{"dept": "IT", "skills": ["c"], "exp": {"yrs": 9}}
]"""
most = {}
for row in json.loads(raw):
if row["skills"]:
dept = row["dept"]
most[dept] = max(most.get(dept, 0), row["exp"]["yrs"])
print(most)
- A.{'IT': 9, 'HR': 7}
- B.{'IT': 15}
- C.{'IT': 9}
- D.{'IT': 5, 'HR': 7}
- E.A KeyError is raised.
Answer: C. {'IT': 9}
json.loads turns the text into a list of dictionaries. An empty list counts as false, so the HR row is skipped. For IT the years are 4, 2 and 9, and max keeps the largest, not the sum. Running it prints {'IT': 9}.
TVK practice question, not from a SEBI paper
Sample 9: Algorithms
Phase II topic. Style: Debugging. Language: Java.
What happens when this Java program runs, and what fixes it?
public class Main {
static int find(int[] a, int key) {
int lo = 0, hi = a.length - 1;
while (lo <= hi) {
int mid = (lo + hi) / 2;
if (a[mid] == key) return mid;
if (a[mid] < key) lo = mid;
else hi = mid - 1;
}
return -1;
}
public static void main(String[] args) {
System.out.println(find(new int[] {2, 4, 6, 8}, 8));
}
}
- A.It never finishes. Change lo = mid; to lo = mid + 1;
- B.It prints 3. No fix is needed.
- C.It prints -1. Change while (lo <= hi) to while (lo < hi).
- D.It throws ArrayIndexOutOfBoundsException. Change hi to a.length - 2.
- E.It never finishes. Change hi = mid - 1; to hi = mid;
Answer: A. It never finishes. Change lo = mid; to lo = mid + 1;
Trace it. lo = 0 and hi = 3 give mid = 1, and 4 < 8 sets lo to 1. Then mid = 2, and 6 < 8 sets lo to 2. Now (2 + 3) / 2 is 2 again, so lo never moves and the loop never ends. Our run printed nothing and we stopped it after 5 seconds. With lo = mid + 1; it prints 3. The other changes do not help: with while (lo < hi), with hi = mid; and with hi set to a.length - 2, the run still had not finished after 5 seconds.
TVK practice question, not from a SEBI paper
Sample 10: Algorithms
Phase II topic. Style: Program dry-run output. Language: C.
What does this C program print?
#include <stdio.h>
int main(void) {
int coins[] = {1, 6, 9};
int amount = 12, dp[13];
dp[0] = 0;
for (int x = 1; x <= amount; x++) {
dp[x] = amount + 1;
for (int i = 0; i < 3; i++)
if (coins[i] <= x && dp[x - coins[i]] + 1 < dp[x])
dp[x] = dp[x - coins[i]] + 1;
}
printf("%d %d\n", dp[9], dp[12]);
return 0;
}
- A.1 4
- B.3 2
- C.1 3
- D.3 4
- E.1 2
Answer: E. 1 2
dp[x] is the fewest coins that make x. dp[9] is 1, using the 9 coin. dp[12] is the smallest of dp[11] + 1, dp[6] + 1 and dp[3] + 1, which are 4, 2 and 4, so it is 2 (6 + 6). A greedy choice would take 9 first and need 9 + 1 + 1 + 1, which is four coins. Running it prints 1 2.
TVK practice question, not from a SEBI paper
Sample 11: Object Oriented Programming
Phase II topic. Style: Syntax understanding. Language: Java.
Which marked line stops this Java program from compiling?
abstract class Shape {
private int id = 1; // line P
abstract double area(); // line Q
int getId() { return id; }
}
class Circle extends Shape {
double area() { return 3.0; }
int twice() { return id * 2; } // line R
}
public class Main {
public static void main(String[] args) {
Shape s = new Circle(); // line S
System.out.println(s.getId() + s.area());
}
}
- A.Line P
- B.Line Q
- C.Line R
- D.Line S
- E.None. It compiles and prints 4.0.
Answer: C. Line R
id is private to Shape, so only code inside Shape can name it. Circle inherits getId() but cannot read id directly. javac reports one error, on line R: id has private access in Shape. Lines P, Q and S are legal: an abstract class can hold a private field and an abstract method, and a Shape variable can hold a new Circle. Change line R to return getId() * 2; and the program compiles and prints 4.0.
TVK practice question, not from a SEBI paper
Sample 12: String Manipulation
Phase II topic. Style: Program dry-run output. Language: Python.
What does this Python program print?
import re
log = "ERR-404 node7; err-500 node12; ERR-42 node3; ERR-503 node9"
codes = re.findall(r"ERR-(\d{3})", log)
first = log[log.find("node"):log.find(";")]
print(codes, first)
- A.['404', '500', '503'] node7
- B.['404', '503'] node7
- C.['ERR-404', 'ERR-503'] node7
- D.['404', '42', '503'] node7
- E.['404', '503'] node12
Answer: B. ['404', '503'] node7
The pattern is case-sensitive, so err-500 does not match. \d{3} needs three digits, so ERR-42 does not match. findall returns only the captured group, so the ERR- part is dropped. find gives the first position of each text, so the slice runs from the first node up to the first semicolon. Running it prints ['404', '503'] node7.