Technical Aptitude

300 practice questions for Technical Aptitude, spanning Programming Fundamentals, Data Structures, Algorithms, and 4 more topics, each with a full worked solution and a Basic, Intermediate, or Advanced difficulty tag.

–
Loading your progress…0/100

Programming Fundamentals

0/20 practiced
Q1

What does this C snippet print:

int x = 5; printf("%d", x++);

?

Solution

x++ is post-increment, so printf reads the current value of x (5) before the increment happens, then x becomes 6 afterward.

Q2

In Python, what does

print(3 * "hello")

output?

Solution

Multiplying a string by an integer repeats it that many times: 3 * "hello" gives "hellohellohello".

Q3

Trace this Java code. What is x afterward:

int x = 10; x += 5;

?

Solution

x += 5 is shorthand for x = x + 5, so x becomes 10 + 5 = 15.

Q4

What gets printed by this C++ snippet:

int a = 3, b = 4; cout << a + b;

?

Solution

a + b evaluates to 3 + 4 = 7, and cout writes 7.

Q5

What effect does this Python code have:

x = [1, 2, 3]; x.append(4)

?

Solution

append(4) adds 4 onto the end of list x, turning it into [1, 2, 3, 4].

Q6

What is the output of this C code:

int x = 8; printf("%d", x >> 1);

?

Solution

x >> 1 shifts the bits right by one place. 8 in binary is 1000, which becomes 0100, i.e. 4.

Q7

What does this Java line output:

boolean x = true; System.out.println(!x);

?

Solution

The ! operator flips a boolean, so !x turns true into false.

Q8

Work out the output of this Python code:

x = 10; y = 3; print(x // y)

?

Solution

// performs floor (integer) division, discarding the remainder: 10 // 3 = 3.

Q9

What does this C++ snippet print:

int x = 5; if(x > 3) cout << "Yes"; else cout << "No";

?

Solution

Since 5 > 3 is true, the if branch runs and prints Yes.

Q10

What is printed by this Python loop:

for i in range(3): print(i)

?

Solution

range(3) produces the sequence 0, 1, 2, and the loop prints each one on its own line.

Q11

What does this C code output:

int x = 3; printf("%d", x & 1);

?

Solution

x & 1 is a bitwise AND. 3 is 11 in binary and 1 is 01; ANDing them gives 01, i.e. 1.

Q12

What is printed by this Java snippet:

int x = 7; System.out.println(x % 2);

?

Solution

% computes the remainder: 7 % 2 leaves a remainder of 1.

Q13

What is the output of this Python code:

x = [1, 2]; x.pop(0); print(x)

?

Solution

pop(0) removes the element at index 0 (which is 1), leaving the list [2].

Q14

What does this C++ code print:

int x = 4; cout << ++x;

?

Solution

++x is pre-increment: x becomes 5 first, and that updated value is what gets printed.

Q15

What is the output of this C snippet:

int x = 5; printf("%d", x | 2);

?

Solution

x | 2 is a bitwise OR. 5 is 101 in binary and 2 is 010; ORing them gives 111, i.e. 7.

Q16

What does this Python code output:

x = {1, 2, 2}; print(len(x))

?

Solution

Sets automatically drop duplicate values, so {1, 2, 2} collapses to {1, 2}, and len reports 2.

Q17

What is printed by this Java code:

String s = "Hello"; System.out.println(s.length());

?

Solution

length() returns the number of characters in the string; "Hello" has 5.

Q18

What is the output of this C++ loop:

int x = 10; while(x > 8) { cout << x << " "; x--; }

?

Solution

The loop keeps running while x > 8, printing 10 then 9 before x drops to 8 and the loop stops.

Q19

What does this Python line output:

x = 5; print(x ** 2)

?

Solution

** is the exponentiation operator: 5 ** 2 = 25.

Q20

What is printed by this C code:

int x = 6; printf("%d", x ^ 3);

?

Solution

x ^ 3 is a bitwise XOR. 6 is 110 and 3 is 011; XORing gives 101, i.e. 5.

Log in to save which questions you've practiced across every category.

Frequently asked questions

What does the Technical Aptitude practice set cover?

300 questions across 3 difficulty levels (100 each of Basic, Intermediate, and Advanced), spanning Programming Fundamentals, Data Structures, Algorithms, and 4 more topics.

Are the answers and solutions shown?

Yes. Every question has a full worked solution and final answer, hidden behind a "Show Answer" toggle so you can genuinely self-test before checking.

Is it free to use?

Yes. Browsing every problem on this page is completely free, with no account required. Creating a free DevsUnite account lets you save your checked-off progress, star favorites, and add personal notes that sync across devices.

Do I need an account to track my progress?

You can read and solve every problem without logging in. An account is only required to mark a problem as done, star it, or add a note. Those actions save to your account instead of resetting on refresh.