Tools


Practice Across Tools

Use the master deck when you want a mixed review of the standalone tools material, then use the master quiz to practice choosing and applying the right command, language feature, or workflow.

Tools Master Flashcards

A comprehensive mix of the standalone tools flashcards: shell, regular expressions, programming-language essentials, Git, Java, C, and Make.

Difficulty: Basic

What does ls do?

Difficulty: Basic

What does mkdir do?

Difficulty: Basic

What does cp do?

Difficulty: Basic

What does mv do?

Difficulty: Basic

What does rm do?

Difficulty: Intermediate

What does less do?

Difficulty: Basic

What does cat do?

Difficulty: Intermediate

What does sed do?

Difficulty: Basic

What does grep do?

Difficulty: Intermediate

What does head do?

Difficulty: Intermediate

What does tail do?

Difficulty: Basic

What does wc do?

Difficulty: Basic

What does sort do?

Difficulty: Intermediate

What does cut do?

Difficulty: Intermediate

What does ssh do?

Difficulty: Intermediate

What does htop do?

Difficulty: Basic

What does pwd do?

Difficulty: Intermediate

What does chmod do?

Difficulty: Basic

You need to see a list of all the files and folders in your current directory. What command do you use?

Difficulty: Basic

You are currently in your home directory and need to navigate into a folder named ‘Documents’. Which command achieves this?

Difficulty: Basic

You want to quickly view the entire contents of a small text file named ‘config.txt’ printed directly to your terminal screen.

Difficulty: Basic

You need to find every line containing the word ‘ERROR’ inside a massive log file called ‘server.log’.

Difficulty: Intermediate

You wrote a new bash script named ‘script.sh’, but when you try to run it, you get a ‘Permission denied’ error. How do you make the file executable?

Difficulty: Basic

You want to rename a file from ‘draft_v1.txt’ to ‘final_version.txt’ without creating a copy.

Difficulty: Basic

You are starting a new project and need to create a brand new, empty folder named ‘src’ in your current location.

Difficulty: Intermediate

You want to view the contents of a very long text file called ‘manual.txt’ one page at a time so you can scroll through it.

Difficulty: Basic

You need to create an exact duplicate of a file named ‘report.pdf’ and save it as ‘report_backup.pdf’.

Difficulty: Basic

You have a temporary file called ‘temp_data.csv’ that you no longer need and want to permanently delete from your system.

Difficulty: Basic

You want to quickly print the phrase ‘Hello World’ to the terminal or pass that string into a pipeline.

Difficulty: Basic

You want to know exactly how many lines are contained within a file named ‘essay.txt’.

Difficulty: Intermediate

You need to perform an automated find-and-replace operation on a stream of text to change the word ‘apple’ to ‘orange’.

Difficulty: Intermediate

You want to store today’s date (formatted as YYYY-MM-DD) in a variable called TODAY so you can use it to name a backup file dynamically.

Difficulty: Intermediate

A variable FILE holds the value my report.pdf. Running rm $FILE fails with a ‘No such file or directory’ error for both ‘my’ and ‘report.pdf’. How do you fix this?

Difficulty: Intermediate

You are writing a script that requires exactly two arguments. How do you check how many arguments were passed to the script so you can print a usage error if the count is wrong?

Difficulty: Intermediate

You want to create a directory called ‘build’ and then immediately run cmake .. inside it, but only if the directory creation succeeded — all in a single command.

Difficulty: Intermediate

At the start of a script, you need to change into /deploy/target. If that directory doesn’t exist, the script must abort immediately — write a defensive one-liner.

Difficulty: Intermediate

You want to delete all files ending in .tmp in the current directory using a single command, without listing each filename explicitly.

Difficulty: Intermediate

You want to count how many lines in server.log contain the word ‘ERROR’.

Difficulty: Intermediate

You have a file names.txt with one name per line. Print only the unique names, sorted alphabetically.

Difficulty: Intermediate

You have a file names.txt with one name per line. Print each unique name alongside a count of how many times it appears.

Difficulty: Intermediate

List all running processes and show only those belonging to user tobias.

Difficulty: Advanced

Print the 3rd line of config.txt without using sed or awk.

Difficulty: Intermediate

List the 5 largest files in the current directory, with the biggest first, showing only their names.

Difficulty: Advanced

You want to replace every occurrence of http:// with https:// in links.txt and save the result to links_secure.txt.

Difficulty: Advanced

Print only the unique error lines from access.log that contain the word ‘ERROR’, sorted alphabetically.

Difficulty: Advanced

Count the total number of files (not directories) inside the current directory tree.

Difficulty: Intermediate

Show the 10 most recently modified files in the current directory, newest first.

Difficulty: Advanced

Extract the second column from comma-separated data.csv, sort the values, and print only the unique ones.

Difficulty: Advanced

Convert the contents of readme.txt to uppercase and save the result to readme_upper.txt.

Difficulty: Intermediate

Print every line from app.log that does NOT contain the word ‘DEBUG’.

Difficulty: Advanced

You have two files, file1.txt and file2.txt. Print all lines from both files that contain the word ‘success’, sorted alphabetically with duplicates removed.

Difficulty: Basic

What metacharacter asserts the start of a string?

Difficulty: Basic

What metacharacter asserts the end of a string?

Difficulty: Basic

What syntax is used to define a Character Class (matching any single character from a specified group)?

Difficulty: Intermediate

What syntax is used inside a character class to act as a negation operator (matching any character NOT in the group)?

Difficulty: Basic

What metacharacter is used to match any single digit?

Difficulty: Basic

What meta character is used to match any ‘word’ character (alphanumeric plus underscore)?

Difficulty: Basic

What meta character is used to match any whitespace character (spaces, tabs, line breaks)?

Difficulty: Basic

What metacharacter acts as a wildcard, matching any single character except a newline?

Difficulty: Basic

What quantifier specifies that the preceding element should match ‘0 or more’ times?

Difficulty: Basic

What quantifier specifies that the preceding element should match ‘1 or more’ times?

Difficulty: Basic

What quantifier specifies that the preceding element should match ‘0 or 1’ time?

Difficulty: Intermediate

What syntax is used to specify that the preceding element must repeat exactly n times?

Difficulty: Basic

What syntax is used to create a group?

Difficulty: Advanced

What is the syntax used to create a Named Group?

Difficulty: Advanced

Write a regex to validate a standard email address (e.g., user@domain.com).

Difficulty: Expert

Write a regex to match a standard US phone number, with optional parentheses and various separators (e.g., 123-456-7890 or (123) 456-7890).

Difficulty: Advanced

Write a regex to match a 3 or 6 digit hex color code starting with a hashtag (e.g., #FFF or #1A2B3C).

Difficulty: Expert

Write a regex to validate a strong password (at least 8 characters, containing at least one uppercase letter, one lowercase letter, and one number).

Difficulty: Expert

Write a regex to match a valid IPv4 address (e.g., 192.168.1.1).

Difficulty: Advanced

Write a regex to extract the domain name from a URL, ignoring the protocol and ‘www’ (e.g., extracting ‘example.com’ from ‘https://www.example.com/page’).

Difficulty: Advanced

Write a regex to match a date in the format YYYY-MM-DD with basic month and day validation.

Difficulty: Advanced

Write a regex to match a time in 24-hour format (HH:MM).

Difficulty: Advanced

Write a regex to match an opening or closing HTML tag.

Difficulty: Intermediate

Write a regex to find all leading and trailing whitespaces in a string (commonly used for string trimming).

Difficulty: Basic

You are shown Python code. Explain what it does and what it returns or prints.

score = 95
gpa = 3.82
print(f"Score: {score}, GPA: {gpa:.1f}")
Difficulty: Basic

You are shown Python code. Explain what it does and what it returns or prints.

7 / 2
7 // 2
Difficulty: Basic

You are shown Python code. Explain what it does and what it returns or prints.

x = "5" + 3
Difficulty: Basic

You are shown Python code. Explain what it does and what it returns or prints.

squares = [x**2 for x in range(1, 6)]
Difficulty: Basic

You are shown Python code. Explain what it does and what it returns or prints.

nums = [4, 8, 15, 16, 23, 42]
big = [x for x in nums if x > 20]
Difficulty: Basic

You are shown Python code. Explain what it does and what it returns or prints.

with open("data.txt") as f:
    for line in f:
        print(line.strip())
Difficulty: Basic

You are shown Python code. Explain what it does and what it returns or prints.

for i, fruit in enumerate(["apple", "banana", "cherry"]):
    print(f"{i}: {fruit}")
Difficulty: Intermediate

You are shown Python code. Explain what it does and what it returns or prints.

import re
codes = re.findall(r'\d+', "Error 404 and 500")
Difficulty: Advanced

You are shown Python code. Explain what it does and what it returns or prints.

import re
clean = re.sub(r'\d+\.\d+\.\d+\.\d+', 'x.x.x.x', text)
Difficulty: Intermediate

You are shown Python code. Explain what it does and what it returns or prints.

import sys
print("Error: file not found", file=sys.stderr)
sys.exit(1)
Difficulty: Intermediate

You are shown Python code. Explain what it does and what it returns or prints.

2 ** 8
2 ^ 8
Difficulty: Intermediate

You are shown Python code. Explain what it does and what it returns or prints.

import sys
filename = sys.argv[1]
Difficulty: Basic

Print a formatted string that says Student: Alice, GPA: 3.82 using a variable name = "Alice" and gpa = 3.82. Format the GPA to 2 decimal places.

Difficulty: Basic

Perform integer (floor) division of 7 by 2, getting 3 as the result (not 3.5).

Difficulty: Basic

Compute 2 to the power of 10 (should give 1024).

Difficulty: Basic

Create a list of the squares of numbers 1 through 5: [1, 4, 9, 16, 25] using a single line of Python.

Difficulty: Basic

From a list nums = [4, 8, 15, 16, 23, 42], create a new list containing only the numbers greater than 20.

Difficulty: Intermediate

Read a file called data.txt line by line, safely closing it even if an error occurs.

Difficulty: Basic

Iterate over a list fruits = ["apple", "banana"] and print both the index and the value.

Difficulty: Intermediate

Find all numbers (sequences of digits) in the string "Error 404 and 500" using regex.

Difficulty: Advanced

Replace all IP addresses in a string text with "x.x.x.x" using regex.

Difficulty: Advanced

Write a script that prints an error to stderr and exits with code 1 if no command-line argument is provided.

Difficulty: Basic

Check the type of a variable x at runtime and print it.

Difficulty: Intermediate

Check if a regex pattern matches anywhere in a string line, returning True or False.

Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

let count = 0;
const MAX = 200;
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

console.log(1 == "1");
console.log(1 === "1");
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const name = "Alice";
console.log(`Hello, ${name}!`);
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const double = n => n * 2;
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const nums = [1, 2, 3, 4, 5];
const evens = nums.filter(n => n % 2 === 0);
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const sum = [1, 2, 3].reduce((acc, n) => acc + n, 0);
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const { name, grade } = { name: "Alice", grade: 95 };
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const [lat, lng] = [40.7, -74.0];
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

setTimeout(() => console.log("B"), 0);
console.log("A");
console.log("C");
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

async function getData() {
    const result = await fetch('/api/data');
    return result.json();
}
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const [a, b] = await Promise.all([fetchA(), fetchB()]);
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const doubled = [1, 2, 3].map(n => n * 2);
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

console.log("Hello from Node.js!");
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const p = new Promise((resolve, reject) => {
    setTimeout(() => resolve("done!"), 100);
});
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

async function getCount() {
    return 42;
}
const result = getCount();
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const city = user?.address?.city;
const port = config.port ?? 3000;
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

let x;
console.log(x);
let y = null;
console.log(y);
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const student = { name: "Alice", grade: 95 };
console.log(student.name);
console.log(student["grade"]);
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const obj = { name: "Bob", grade: 42 };
const json = JSON.stringify(obj);
const back = JSON.parse(json);
Difficulty: Intermediate

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

const students = [{ id: 1, name: "Alice" }, { id: 2, name: "Bob" }];
const found = students.find(s => s.id === 2);
Difficulty: Basic

You are shown JavaScript/Node.js code. Explain what it does and what it outputs.

if (score >= 90) {
    console.log("A");
} else if (score >= 60) {
    console.log("Pass");
} else {
    console.log("Fail");
}
Difficulty: Basic

Declare a mutable variable count set to 0 and an immutable constant MAX set to 200.

Difficulty: Intermediate

Check if a variable userInput (which might be a string) equals the number 42, without being tricked by type coercion.

Difficulty: Basic

Create a string that says Hello, Alice! Score: 95 using variables name = "Alice" and score = 95, with interpolation.

Difficulty: Basic

Write an arrow function add that takes two parameters and returns their sum.

Difficulty: Basic

Given const nums = [1, 2, 3, 4, 5], create a new array containing only the even numbers using a higher-order function.

Difficulty: Basic

Given const nums = [1, 2, 3], create a new array where each number is doubled.

Difficulty: Intermediate

Compute the sum of [1, 2, 3, 4, 5] using a single expression.

Difficulty: Basic

Extract name and grade from const student = { name: "Alice", grade: 95 } into separate variables in one line.

Difficulty: Intermediate

Schedule a function to run after the current call stack empties (with minimal delay).

Difficulty: Advanced

Write an async function loadUser that fetches user data from /api/user, handles errors, and logs the result.

Difficulty: Intermediate

Fetch two independent API endpoints in parallel (not sequentially) and assign the results to a and b.

Difficulty: Intermediate

Write a function that accepts an object parameter with name and grade properties, using destructuring in the parameter list.

Difficulty: Advanced

Write a delay(ms) function that returns a Promise which resolves after ms milliseconds.

Difficulty: Advanced

Safely read response.data.user.name where any part of the chain might be null or undefined. Fall back to 'Anonymous' if missing.

Difficulty: Basic

Create a JavaScript object with properties name (“Alice”) and grade (95), then convert it to a JSON string.

Difficulty: Intermediate

Given const students = [{ id: 1, name: 'Alice' }, { id: 2, name: 'Bob' }], find the student with id === 2 (return the object, not an array).

Difficulty: Basic

Declare a variable with no initial value. What is its value? Then set a different variable explicitly to ‘nothing’.

Difficulty: Basic

Write a for...of loop that iterates over const names = ['Alice', 'Bob', 'Carol'] and logs each name.

Difficulty: Basic

You are shown React/JSX code. Explain what it does and what it renders.

function App() {
  return <h1 style={{color: '#2774AE'}}>Hello!</h1>;
}
Difficulty: Basic

You are shown React/JSX code. Explain what it does and what it renders.

<ProductCard name="Laptop" price={999.99} />
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

function Card({ title, children }) {
  return <div className="card"><h2>{title}</h2>{children}</div>;
}
Difficulty: Basic

You are shown React/JSX code. Explain what it does and what it renders.

const [count, setCount] = React.useState(0);
Difficulty: Basic

You are shown React/JSX code. Explain what it does and what it renders.

<button onClick={() => setCount(count + 1)}>+1</button>
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

{tasks.map(task => <li key={task.id}>{task.text}</li>)}
Difficulty: Basic

You are shown React/JSX code. Explain what it does and what it renders.

{isLoggedIn ? <Dashboard /> : <LoginForm />}
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

{unreadCount > 0 && <Badge count={unreadCount} />}
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

setItems([...items, newItem]);
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

<SearchBar value={text} onChange={setText} />
Difficulty: Basic

You are shown React/JSX code. Explain what it does and what it renders.

<img src={url} alt="logo" />
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

function Badge({ label, color }) {
  return (
    <span style={{background: color, padding: '4px 12px', borderRadius: 12}}>
      {label}
    </span>
  );
}
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

useEffect(() => {
  document.title = 'Hello!';
}, []);
Difficulty: Advanced

You are shown React/JSX code. Explain what it does and what it renders.

useEffect(() => {
  fetch(`/api/users/${userId}`)
    .then(res => res.json())
    .then(data => setUser(data));
}, [userId]);
Difficulty: Advanced

You are shown React/JSX code. Explain what it does and what it renders.

setCount(prev => prev + 1);
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

setItems(items.filter(item => item.id !== targetId));
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

setUser({ ...user, name: 'Bob' });
Difficulty: Intermediate

You are shown React/JSX code. Explain what it does and what it renders.

<input
  value={query}
  onChange={e => setQuery(e.target.value)}
/>
Difficulty: Basic

Write a React component Greeting that renders an <h1> saying Hello, Alice! using a variable name.

Difficulty: Intermediate

Write JSX that applies an inline style with a blue background and white text to a <div>.

Difficulty: Advanced

Write a component ProductCard that accepts name, price, and onSale props. Show the name in an <h3>, the price formatted to 2 decimals, and a ‘Sale!’ span only when onSale is true.

Difficulty: Basic

Declare a state variable count with initial value 0 using React’s useState hook.

Difficulty: Intermediate

Create a button that increments a count state variable by 1 when clicked.

Difficulty: Intermediate

Render a list of users (each with id and name) as <li> elements with proper keys.

Difficulty: Basic

Show <Dashboard /> if isLoggedIn is true, otherwise show <LoginForm />.

Difficulty: Intermediate

Show a <Badge /> only when count is greater than 0. Be careful not to render the number 0.

Difficulty: Intermediate

Add an item to an array stored in state (items/setItems) without mutating the original array.

Difficulty: Intermediate

Write a generic Card component that wraps any content passed between its opening and closing tags.

Difficulty: Advanced

Pass a callback function from a parent to a child component so the child can update the parent’s state.

Difficulty: Basic

Use className (not class) to apply the CSS class app-title to an <h1> element in JSX.

Difficulty: Advanced

Write a useEffect that calls fetchPosts() once when a component mounts, storing the result in a posts state variable. Assume fetchPosts() returns a Promise that resolves to an array.

Difficulty: Advanced

Write a counter that increments correctly even if the button is clicked many times rapidly. Use the functional update pattern.

Difficulty: Intermediate

Remove the item with id === deletedId from the tasks state array.

Difficulty: Intermediate

Update the score field of the player state object to newScore, keeping all other fields unchanged.

Difficulty: Basic

Render an <h2> and a <p> side by side as siblings without adding a wrapper <div> to the DOM.

Difficulty: Advanced

Write a controlled text input that is bound to a username state variable. Every keystroke should update the state.

Difficulty: Intermediate

You have some uncommitted, incomplete changes in your working directory, but you need to switch to another branch to urgently fix a bug. How do you temporarily save your current work without making a messy commit?

Difficulty: Intermediate

You know a bug was introduced recently, but you aren’t sure which commit caused it. How do you perform a binary search through your commit history to find the exact commit that broke the code?

Difficulty: Intermediate

You are looking at a file and want to know exactly who last modified a specific line of code, and in which commit they did it.

Difficulty: Intermediate

You want to safely ‘undo’ a previous commit that introduced an error, but you don’t want to rewrite history or force-push. How do you create a new commit with the exact inverse changes?

Difficulty: Intermediate

You want to see exactly what has changed in your working directory compared to your last saved snapshot (the most recent commit).

Difficulty: Advanced

You have a feature branch with several experimental commits, but you only want to move one specific, completed commit over to your main branch.

Difficulty: Advanced

You want to integrate a feature branch into main, but instead of bringing over all 15 tiny incremental commits, you want them combined into one clean commit on the main branch.

Difficulty: Advanced

You are building a massive project and want to include an entirely separate external Git repository as a subdirectory within your project, while keeping its history independent.

Difficulty: Basic

You are starting a brand new project in an empty folder on your computer and want Git to start tracking changes in this directory.

Difficulty: Basic

You have just installed Git on a new computer and need to set up your username and email address so that your commits are properly attributed to you.

Difficulty: Basic

You’ve made changes to three different files, but you only want two of them to be included in your next snapshot. How do you move those specific files to the staging area?

Difficulty: Basic

You’ve lost track of what you’ve been doing. You want a quick overview of which files are modified, which are staged, and which are completely untracked by Git.

Difficulty: Basic

You have staged all the files for a completed feature and are ready to permanently save this snapshot to your local repository’s history with a descriptive message.

Difficulty: Basic

You want to review the chronological history of all past commits on your current branch, including their author, date, and commit message.

Difficulty: Intermediate

You’ve made edits to a file but haven’t staged it yet. You want to see the exact lines of code you added or removed compared to what is currently in the staging area.

Difficulty: Basic

You want to create a new branch pointer for a future feature without switching branches yet. Which command creates that branch at your current commit?

Difficulty: Basic

You are currently on your feature branch and need to switch your working directory back to the ‘main’ branch.

Difficulty: Intermediate

Your feature branch is complete, and you want to integrate its entire commit history into your current ‘main’ branch.

Difficulty: Advanced

Instead of creating a merge commit, you want to take the commits from your feature branch and re-apply them directly on top of the latest ‘main’ branch to create a clean, linear history.

Difficulty: Basic

You want to start working on an open-source project hosted on GitHub. How do you download a full local copy of that repository to your machine?

Difficulty: Intermediate

Your team members have uploaded new commits to the shared remote repository. You want to fetch those changes and immediately integrate them into your current local branch.

Difficulty: Basic

You have finished making several commits locally and want to upload them to the remote GitHub repository so your team can see them.

Difficulty: Intermediate

You have a specific commit hash and want to see detailed information about it, including the commit message, author, and the exact code diff it introduced.

Difficulty: Intermediate

You want to start working on a new feature in isolation. How do you create a new branch called ‘feature-auth’ and immediately switch to it in a single command?

Difficulty: Intermediate

You accidentally staged a file you didn’t intend to include in your next commit. How do you move it back to the working directory without losing your modifications?

Difficulty: Intermediate

You made some experimental changes to a file but want to discard them entirely and revert to the version from your last commit.

Difficulty: Advanced

You merge a feature branch into main, and Git performs the merge without creating a new merge commit — it simply moves the ‘main’ pointer forward. What type of merge is this, and when does it occur?

Difficulty: Advanced

You want to safely inspect the codebase at a specific older commit without modifying any branch. How do you do this?

Difficulty: Intermediate

You want to safely ‘undo’ a previous commit that introduced an error, but you don’t want to rewrite history or force-push. How do you create a new commit with the exact inverse changes?

Difficulty: Intermediate

You want to see exactly what has changed in your working directory compared to your last saved snapshot (the most recent commit).

Difficulty: Basic

You are starting a brand new project in an empty folder on your computer and want Git to start tracking changes in this directory.

Difficulty: Basic

You have just installed Git on a new computer and need to set up your username and email address so that your commits are properly attributed to you.

Difficulty: Basic

You’ve made changes to three different files, but you only want two of them to be included in your next snapshot. How do you move those specific files to the staging area?

Difficulty: Basic

You’ve lost track of what you’ve been doing. You want a quick overview of which files are modified, which are staged, and which are completely untracked by Git.

Difficulty: Basic

You have staged all the files for a completed feature and are ready to permanently save this snapshot to your local repository’s history with a descriptive message.

Difficulty: Basic

You want to review the chronological history of all past commits on your current branch, including their author, date, and commit message.

Difficulty: Intermediate

You’ve made edits to a file but haven’t staged it yet. You want to see the exact lines of code you added or removed compared to what is currently in the staging area.

Difficulty: Basic

You want to create a new branch pointer for a future feature without switching branches yet. Which command creates that branch at your current commit?

Difficulty: Basic

You are currently on your feature branch and need to switch your working directory back to the ‘main’ branch.

Difficulty: Intermediate

Your feature branch is complete, and you want to integrate its entire commit history into your current ‘main’ branch.

Difficulty: Basic

You want to start working on an open-source project hosted on GitHub. How do you download a full local copy of that repository to your machine?

Difficulty: Intermediate

Your team members have uploaded new commits to the shared remote repository. You want to fetch those changes and immediately integrate them into your current local branch.

Difficulty: Basic

You have finished making several commits locally and want to upload them to the remote GitHub repository so your team can see them.

Difficulty: Intermediate

You have a specific commit hash and want to see detailed information about it, including the commit message, author, and the exact code diff it introduced.

Difficulty: Intermediate

You want to start working on a new feature in isolation. How do you create a new branch called ‘feature-auth’ and immediately switch to it in a single command?

Difficulty: Intermediate

You accidentally staged a file you didn’t intend to include in your next commit. How do you move it back to the working directory without losing your modifications?

Difficulty: Intermediate

You made some experimental changes to a file but want to discard them entirely and revert to the version from your last commit.

Difficulty: Advanced

You merge a feature branch into main, and Git performs the merge without creating a new merge commit — it simply moves the ‘main’ pointer forward. What type of merge is this, and when does it occur?

Difficulty: Intermediate

You have some uncommitted, incomplete changes in your working directory, but you need to switch to another branch to urgently fix a bug. How do you temporarily save your current work without making a messy commit?

Difficulty: Intermediate

You know a bug was introduced recently, but you aren’t sure which commit caused it. How do you perform a binary search through your commit history to find the exact commit that broke the code?

Difficulty: Intermediate

You are looking at a file and want to know exactly who last modified a specific line of code, and in which commit they did it.

Difficulty: Advanced

You have a feature branch with several experimental commits, but you only want to move one specific, completed commit over to your main branch.

Difficulty: Advanced

You want to integrate a feature branch into main, but instead of bringing over all 15 tiny incremental commits, you want them combined into one clean commit on the main branch.

Difficulty: Advanced

You are building a massive project and want to include an entirely separate external Git repository as a subdirectory within your project, while keeping its history independent.

Difficulty: Advanced

Instead of creating a merge commit, you want to take the commits from your feature branch and re-apply them directly on top of the latest ‘main’ branch to create a clean, linear history.

Difficulty: Advanced

You want to safely inspect the codebase at a specific older commit without modifying any branch. How do you do this?

Difficulty: Intermediate
String a = new String("hello");
String b = new String("hello");
System.out.println(a == b);        // Line A
System.out.println(a.equals(b));   // Line B

Predict each output. Then explain why Line A and Line B differ — what does each operator actually check?

Difficulty: Advanced
Integer x = 127;
Integer y = 127;
System.out.println(x == y);   // true

Integer p = 128;
Integer q = 128;
System.out.println(p == q);   // false

The only change is 127 → 128. What mechanism in the JVM causes this flip, and why is this dangerous in production code?

Difficulty: Intermediate
Integer count = null;
int n = count;  // what happens here?

Describe exactly what the JVM does on the second line and what error results.

Difficulty: Advanced
// Version A
Integer sum = 0;
for (int i = 0; i < 1_000_000; i++) {
    sum += i;
}

// Version B
int sum = 0;
for (int i = 0; i < 1_000_000; i++) {
    sum += i;
}

Both produce the same final value. Analyze what the JVM does differently in Version A on every iteration. Which version should you use?

Difficulty: Intermediate
public class BankAccount {
    public String owner;
    public double balance;
    ...
}

The fields are public. Explain what specific harm this causes compared to making them private with a withdraw() method that validates before mutating.

Difficulty: Advanced
class GradeReport {
    private ArrayList<Integer> scores;

    public ArrayList<Integer> getScores() { return scores; }
}

The field is private. A colleague says “information hiding is achieved.” Are they right? What would break if you later switch scores to int[]?

Difficulty: Intermediate
public interface Shape {
    double getArea();
    double getPerimeter();
}

public class Circle implements Shape {
    private double radius;
    public Circle(double r) { this.radius = r; }

    @Override
    public double getArea() { return Math.PI * radius * radius; }

    @Override
    public double getPerimeter() { return 2 * Math.PI * radius; }
}

Shape s = new Circle(5.0);
System.out.println(s.getArea());

Explain what @Override buys you here. Give an example of the specific bug it prevents.

Difficulty: Advanced
abstract class Vehicle {
    private String make;
    public Vehicle(String make) { this.make = make; }
    public String getMake() { return make; }
    public abstract String describe();
}

class Car extends Vehicle {
    public Car(String make) {
        super(make);       // ← this line
    }
    @Override
    public String describe() { return getMake() + " Car"; }
}

Why must super(make) be the first statement in Car’s constructor? What would happen if it were moved after getMake()?

Difficulty: Advanced
Vehicle[] fleet = {
    new Car("Toyota", 2024),
    new Motorcycle("Harley", 2023),
};
for (Vehicle v : fleet) {
    System.out.println(v.describe());
}

The reference type is Vehicle, but describe() is abstract. Describe precisely what happens at compile time and at runtime when v.describe() is called.

Difficulty: Advanced
public class Pair<A, B> {
    private A first;
    private B second;

    public static <X, Y> Pair<Y, X> swap(Pair<X, Y> p) {
        return new Pair<>(p.getSecond(), p.getFirst());
    }
}

Why does swap declare its own type parameters <X, Y> instead of reusing the class’s <A, B>?

Difficulty: Advanced
Map<String, Integer> scores = new HashMap<>();
scores.put("Alice", 95);
int grade = scores.get("Bob");  // Bob not in map

This compiles without warnings. Predict what happens at runtime and explain the chain of events.

Difficulty: Intermediate
public class SafeCalculator {
    public double divide(int a, int b) throws CalculatorException {
        if (b == 0) throw new CalculatorException("Division by zero");
        return (double) a / b;
    }
}

class CalculatorException extends Exception {
    public CalculatorException(String msg) { super(msg); }
}

CalculatorException extends Exception, not RuntimeException. What concrete difference does this choice produce for callers of divide()?

Difficulty: Intermediate
// Version A
public double average(ArrayList<Integer> scores) { ... }

// Version B
public double average(List<Integer> scores) { ... }

Both compile. Analyze the practical difference when other code calls average().

Difficulty: Intermediate
Set<String> submitted = new HashSet<>();
List<String> roster = new ArrayList<>();

submitted.add("Alice");
submitted.add("Alice");  // duplicate

roster.add("Alice");
roster.add("Alice");     // duplicate

System.out.println(submitted.size());  // ?
System.out.println(roster.size());     // ?

Predict each output and explain what design principle drives the difference between HashSet and ArrayList.

Difficulty: Advanced
public class Course implements Enrollable {
    private ArrayList<Student> students = new ArrayList<>();

    public boolean isEnrolled(String name) {
        for (Student s : students) {
            if (s.getName().equals(name)) return true;
        }
        return false;
    }
}

This works correctly. Evaluate it for performance and explain what would change if you swapped ArrayList<Student> for HashMap<String, Student>.

Difficulty: Basic

Two String variables input and stored may or may not point to the same object. Write a boolean expression that checks whether they contain the same characters, guaranteed to be correct regardless of how they were created.

Difficulty: Intermediate

A HashMap lookup is crashing in production with a NullPointerException. The code is:

Map<String, Integer> grades = loadFromDB();
int g = grades.get(studentId);

Fix it in one line, defaulting to 0 for missing students.

Difficulty: Advanced

Design a BankAccount class that:

  • Stores owner (String) and balance (double) — neither directly accessible from outside
  • Provides a constructor, getOwner(), getBalance()
  • deposit(double amount) — only accepts positive amounts
  • withdraw(double amount) — returns false if insufficient funds; true on success
  • toString() returns "BankAccount[owner=Alice, balance=100.0]"
Difficulty: Expert

This class has a design problem. Identify it, then rewrite GradeReport so that changing the grading thresholds (A ≥ 90, B ≥ 80…) requires editing only one method:

class GradeReport {
    private List<Integer> scores;
    public List<Integer> getScores() { return scores; }
}

// In main:
for (int s : report.getScores()) {
    if (s >= 90) System.out.println("A");
    else if (s >= 80) System.out.println("B");
}
Difficulty: Intermediate

Define a Drawable interface with one method: String draw(). Then write a Square class that implements it — draw() returns "Square(side=5.0)".

Difficulty: Advanced

Design an abstract class Animal with:

  • A private String name and a constructor
  • A concrete getName() getter
  • An abstract method makeSound() that returns a String

Then write a Dog subclass that calls the parent constructor and returns "Woof!" from makeSound().

Difficulty: Intermediate

Write a generic class Box<T> that holds one item of any type. Include a constructor, a getItem() method, and a setItem() method.

Difficulty: Advanced

Write a generic static method findMax that takes two arguments of any type and returns the larger one. The type must be constrained to types that can be compared.

Difficulty: Expert

Write a WordCounter class that takes a String[] in its constructor and provides:

  • int getCount(String word) — returns 0 for unknown words, no NPE
  • int getUniqueCount() — number of distinct words

Use the most appropriate collection for each responsibility.

Difficulty: Advanced

Define a checked exception EnrollmentException and a Course.enroll(Student s) method that throws it when the course is full (capacity exceeded). Write both the class definition and the calling code that handles the exception.

Difficulty: Intermediate

Write a try-catch-finally block that: opens a file (throws IOException), reads its content, and prints an error if it fails. The finally block should always print "Done.".

Difficulty: Advanced

You need to store course enrollments. Two options:

  • List<Student> with a manual duplicate check in enroll()
  • LinkedHashSet<Student> that handles duplicates automatically

Implement enroll(Student s) using each approach, then state which is preferable and why.

Difficulty: Intermediate

Write a method printAll(List<String> items) that iterates the list with an enhanced for-loop, printing each item. Then call it with an ArrayList<String> and a LinkedList<String>. Explain why both calls compile.

Difficulty: Expert

You are building a course registration system. Design the method signature (interface method + throws) for an Enrollable interface that:

  • Adds a student (can fail if course is full or duplicate)
  • Removes a student by name (returns whether it succeeded)
  • Checks enrollment by name
  • Returns a list of enrolled student names
Difficulty: Advanced

A teammate wrote this accumulator. Find the performance issue, explain the root cause, and write the corrected version.

Integer total = 0;
for (String word : words) {
    if (word.length() > 5) total++;
}
Difficulty: Basic

What does void* malloc(size_t size) return on success, and what does it return when the OS cannot satisfy the request?

Difficulty: Intermediate

In C, what is '\0'? Distinguish it from '0' and explain why C strings need it.

Difficulty: Advanced

Why does C have no function overloading? Explain the design tradeoff.

Difficulty: Intermediate

Explain the difference between char and char* in C.

char  c = 'A';
char* s = "Alice";
Difficulty: Intermediate

Predict what this program prints:

#include <stdio.h>
int main(void) {
    int   n = 42;
    float f = 3.5;
    printf("n=%d f=%.1f size=%zu\n", n, f, sizeof(n));
    return 0;
}
Difficulty: Intermediate

Write a C function void swap(int* a, int* b) that swaps the values pointed to by a and b, plus the call site that swaps two local variables x and y.

Difficulty: Advanced

Allocate a flat rows × cols matrix of int on the heap, write the index expression for element (i, j) in row-major order, and free the allocation.

Difficulty: Advanced

What is the bug in this code, and what is the most likely runtime symptom?

char* greeting(void) {
    char buf[64];
    snprintf(buf, sizeof(buf), "Hello, world!");
    return buf;
}
Difficulty: Intermediate

What is the role of libc, and how does it relate to operating-system system calls?

Difficulty: Advanced

Walk through what happens at runtime when this code executes:

int* p = malloc(sizeof(int));
*p = 7;
free(p);
free(p);
Difficulty: Expert

Name two distinct production scenarios where you would deliberately choose C over C++, and explain why each scenario favors C.

Difficulty: Advanced

Almost every major language (Python, Java, C#, Rust, Go, Ruby) supports calling into a C library. Browser JavaScript does not — and this is not an accident. What is the design rationale?

Difficulty: Advanced

Design a C struct for a singly-linked-list node that stores an int value. Then write the prototype for a function list_prepend that takes the current head and an int, and returns the new head.

Difficulty: Advanced

Compare static and dynamic linking on three axes: when linking happens, what gets shipped, and the consequence for security updates.

Difficulty: Basic

What is the standard syntax to define a basic build rule in a Makefile?

Difficulty: Basic

What specific whitespace character MUST be used to indent the command/recipe lines in a Makefile rule?

Difficulty: Basic

How do you reference a variable (or macro) named ‘CC’ in a Makefile command?

Difficulty: Basic

What Automatic Variable represents the file name of the target of the rule?

Difficulty: Intermediate

What Automatic Variable represents the name of the first prerequisite?

Difficulty: Intermediate

What Automatic Variable represents the names of all the prerequisites, with spaces between them?

Difficulty: Intermediate

What wildcard character is used to define a Pattern Rule (a generic rule applied to multiple files)?

Difficulty: Intermediate

What special target is used to declare that a target name is an action (like ‘clean’) and not an actual file to be created?

Difficulty: Advanced

What metacharacter can be placed at the very beginning of a recipe command to suppress make from echoing the command to the terminal?

Difficulty: Advanced

What syntax is used for string substitution on a variable, such as changing all .c extensions in $(SRCS) to .o?

Difficulty: Intermediate

Write a basic Makefile rule to compile a single C source file (main.c) into an executable named app.

Difficulty: Intermediate

Write a Makefile snippet that defines variables for the C compiler (gcc) and standard compilation flags (-Wall -g), and uses them to compile main.c into main.o.

Difficulty: Advanced

Write a standard clean target that removes all .o files and an app executable, ensuring it runs even if a file literally named ‘clean’ is created in the directory.

Difficulty: Advanced

Write a generic pattern rule to compile any .c file into a corresponding .o file, using automatic variables for the target name and the first prerequisite.

Difficulty: Advanced

Given a variable SRCS = main.c utils.c, write a variable definition for OBJS that dynamically replaces the .c extension with .o for all files in SRCS.

Difficulty: Advanced

Write a rule to link an executable myprog from a list of object files stored in the $(OBJS) variable, using the automatic variable that lists all prerequisites.

Difficulty: Intermediate

Write the conventional default target rule that is used to build multiple executables (e.g., app1 and app2) when a user simply types make without specifying a target.

Difficulty: Advanced

Write a run target that executes an output file named ./app, but suppresses make from printing the command to the terminal before running it.

Difficulty: Advanced

Write a variable definition SRCS that uses a Make function to dynamically find and list all .c files in the current directory.

Difficulty: Intermediate

Write a generic rule to create a build directory build/ using the mkdir command.

Difficulty: Intermediate

Given the snippet app: main.o network.o utils.o followed by the command $(CC) $(CFLAGS) $^ -o $@, what exactly does the command evaluate to if CC=gcc and CFLAGS=-Wall?

Difficulty: Intermediate

If a C project Makefile contains SRCS = main.c math.c io.c and OBJS = $(SRCS:.c=.o), what does OBJS evaluate to?

Difficulty: Intermediate

Read this common pattern rule: %.o: %.c followed by $(CC) $(CFLAGS) -c $< -o $@. If make uses this rule to build utils.o from utils.c, what does $< represent?

Difficulty: Advanced

You see the line CC ?= gcc at the top of a Makefile. What happens if a developer compiles the project by typing make CC=clang in their terminal?

Difficulty: Intermediate

A C project has a rule clean: rm -f *.o myapp. Why is it critical to also include .PHONY: clean in this Makefile?

Difficulty: Advanced

In the rule main.o: main.c main.h types.h, what happens if you edit and save types.h?

Difficulty: Advanced

You are reading a Makefile and see @echo "Compiling $@..." followed by @$(CC) -c $< -o $@. What do the @ symbols do?

Difficulty: Intermediate

What is the conventional purpose of the CFLAGS variable in a C Makefile?

Difficulty: Advanced

What is the conventional purpose of the LDFLAGS or LDLIBS variables in a C Makefile?

Difficulty: Intermediate

A C project has multiple executables: a server and a client. The Makefile starts with all: server client. What happens if you just type make?

Tools Master Quiz

A comprehensive mix of the standalone tools quizzes: shell, regular expressions, programming-language essentials, Git, Java, C, and Make.

Difficulty: Intermediate

A developer needs to parse a massive log file, extract IP addresses, sort them, and count unique occurrences. Instead of writing a 500-line Python script, they use grep | cut | sort | uniq -c. Why is this approach fundamentally preferred in the UNIX environment?

Correct Answer:
Difficulty: Intermediate

A script runs a command that generates both useful output and a flood of permission error messages. The user runs script.sh > output.txt, but the errors still clutter the terminal screen while the useful data goes to the file. What underlying concept explains this behavior?

Correct Answer:
Difficulty: Advanced

A C++ developer writes a Bash script with a for loop. Inside the loop, they declare a variable temp_val. After the loop finishes, they try to print temp_val expecting it to be undefined or empty, but it prints the last value assigned in the loop. Why did this happen?

Correct Answer:
Difficulty: Advanced

You want to use a command that requires two file inputs (like diff), but your data is currently coming from the live outputs of two different commands. Instead of creating temporary files on the disk, you use the <(command) syntax. What is this concept called and what does it achieve?

Correct Answer:
Difficulty: Intermediate

A script contains entirely valid Python code, but the file is named script.sh and has #!/bin/bash at the very top. When executed via ./script.sh, the terminal throws dozens of ‘command not found’ and syntax errors. What is the fundamental misunderstanding here?

Correct Answer:
Difficulty: Intermediate

A developer uses the regular expression [0-9]{4} to validate that a user’s input is exactly a four-digit PIN. However, the system incorrectly accepts ‘12345’ and ‘A1234’. What crucial RegEx concept did the developer omit?

Correct Answer:
Difficulty: Advanced

You are designing a data pipeline in the shell. Which of the following statements correctly describe how UNIX handles data streams and command chaining? (Select all that apply)

Correct Answers:
Difficulty: Intermediate

You’ve written a shell script deploy.sh but it throws a ‘Permission denied’ error or fails to run when you type ./deploy.sh. Which of the following are valid reasons or necessary steps to successfully execute a script as a standalone program? (Select all that apply)

Correct Answers:
Difficulty: Advanced

In Bash, exit codes are crucial for determining if a command succeeded or failed. Which of the following statements are true regarding how Bash handles exit statuses and control flow? (Select all that apply)

Correct Answers:
Difficulty: Advanced

When you type a command like python or grep into the terminal, the shell knows exactly what program to run without you providing the full file path. How does the $PATH environment variable facilitate this, and how is it managed? (Select all that apply)

Correct Answers:
Difficulty: Intermediate

A developer writes LOGFILE="access errors.log" and then runs wc -l $LOGFILE. The command fails with ‘No such file or directory’ errors for both ‘access’ and ‘errors.log’. What is the root cause?

Correct Answer:
Difficulty: Basic

A script is invoked with ./deploy.sh production 8080 myapp. Inside the script, which variable holds the value 8080?

Correct Answer:
Difficulty: Intermediate

A script contains the line: cd /deploy/target && ./run_tests.sh && echo 'All tests passed!'. If ./run_tests.sh exits with a non-zero status code, what happens next?

Correct Answer:
Difficulty: Advanced

Which of the following statements correctly describe Bash quoting and command substitution behavior? (Select all that apply)

Correct Answers:
Difficulty: Advanced

Arrange the pipeline fragments to build a command that extracts all ERROR lines from a log, sorts them, removes duplicates, and counts how many unique errors remain.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
grep 'ERROR' server.log|sort|uniq|wc -l
Difficulty: Expert

Arrange the lines to write a shell script that validates a command-line argument, prints an error to stderr if missing, and exits with a non-zero code. Otherwise it prints a logging message.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
#!/bin/bash
if [ $# -lt 1 ]; then
echo "Error: no filename given" >&2
exit 1
fi
echo "Processing $1..."
Difficulty: Expert

Arrange the pipeline fragments to find the 5 most frequently occurring IP addresses in an access log.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
grep -oE '[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+' access.log|sort|uniq -c|sort -rn|head -5
Difficulty: Advanced

Arrange the fragments to redirect both stdout and stderr of a deployment script into a single log file.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
./deploy.sh>output.log2>&1
Difficulty: Advanced

Arrange the pipeline to count how many files under src/ contain the word TODO.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
grep -rl 'TODO' src/|wc -l
Difficulty: Intermediate

Arrange the fragments to grant execute permission on a script and immediately run it.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
chmod +x script.sh&&./script.sh
Difficulty: Intermediate

You are working inside project/ which currently has this structure:

Detailed description

Folder tree rooted at project/ with 2 folders and 3 files. Top-level entries: README.md, src/.

Entries

  • project/ (folder)
  •  README.md (file)
  •  src/ (folder)
  •   app.js (file)
  •   utils.js (file)

You run mkdir src/components/ui. What is the result?

Correct Answer:
Difficulty: Intermediate

You are working inside project/ which currently has this structure:

Detailed description

Folder tree rooted at project/ with 4 folders and 5 files. Top-level entries: README.md, build/, src/.

Entries

  • project/ (folder)
  •  README.md (file)
  •  build/ (folder)
  •   main.o (file)
  •   helper.o (file)
  •   output/ (folder)
  •    app (file)
  •  src/ (folder)
  •   app.c (file)

You run rm build/ from inside project/. What is the result?

Correct Answer:
Difficulty: Advanced

Arrange the fragments to find which lines appear most often in access.log — showing the top 5 repeated entries with their counts.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
sort access.log|uniq -c|sort -rn|head -5
Difficulty: Advanced

Arrange the fragments to count how many unique lines containing "error" (case-insensitive) exist in app.log.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
grep -i 'error' app.log|sort|uniq|wc -l
Difficulty: Intermediate

Arrange the fragments to combine two log files and display every unique line in sorted order.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
cat server.log error.log|sort|uniq
Difficulty: Advanced

Arrange the fragments to display only the non-comment, non-blank lines from config.txt, sorted alphabetically.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
grep -v '^#' config.txt|grep -v '^$'|sort
Difficulty: Intermediate

Arrange the fragments to count how many .txt files are in the current directory.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
ls|grep '\.txt$'|wc -l
Difficulty: Advanced

You are tasked with extracting all data enclosed in HTML <div> tags. You write a regular expression, but it consistently fails on deeply nested divs (e.g., <div><div>text</div></div>). From a theoretical computer science perspective, why is standard RegEx the wrong tool for this?

Correct Answer:
Difficulty: Advanced

A developer writes a regex to parse a log file: ^.*error.*$. They notice that while it works, it runs much slower than expected on very long log lines. What underlying behavior of the .* token is causing this inefficiency?

Correct Answer:
Difficulty: Advanced

You need to validate user input to ensure a password contains both a number and a special character, but you don’t know what order they will appear in. What mechanism allows a RegEx engine to assert these conditions without actually ‘consuming’ the string character by character?

Correct Answer:
Difficulty: Advanced

You are given the regex (?P<year>\d{4})-(?P<month>\d{2})-(?P<day>\d{2}) and apply it to the string 2026-04-01. After a successful match, which of the following correctly describes how you can access the captured month value?

Correct Answer:
Difficulty: Intermediate

When writing a complex regex to extract phone numbers, you use parentheses (...) to group the area code so you can apply a ? quantifier. However, you also want to extract the area code by name for later use in your code. What is the best approach?

Correct Answer:
Difficulty: Intermediate

You write a regex to ensure a username is strictly alphanumeric: [a-zA-Z0-9]+. However, a user successfully submits the username admin!@#. Why did this happen?

Correct Answer:
Difficulty: Advanced

Which of the following scenarios are highly appropriate use cases for Regular Expressions? (Select all that apply)

Correct Answers:
Difficulty: Intermediate

In the context of evaluating a regex for data extraction, what represents a ‘False Positive’ and a ‘False Negative’? (Select all that apply)

Correct Answers:
Difficulty: Intermediate

You use the regex <.*> to extract a single HTML tag from <b>bold</b> text, but it matches the entire string <b>bold</b> instead of just <b>. What is the simplest fix?

Correct Answer:
Difficulty: Advanced

Which of the following statements about Lookaheads (?=...) are true? (Select all that apply)

Correct Answers:
Difficulty: Advanced

Arrange the regex fragments to build a pattern that validates a simple email address like user@example.com. The pattern should be anchored to match the entire string.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$
Difficulty: Intermediate

Arrange the regex fragments to build a pattern that matches a date in YYYY-MM-DD format (e.g., 2024-01-15). Anchor the pattern.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
^\d{4}-\d{2}-\d{2}$
Difficulty: Advanced

Arrange the regex fragments to extract the protocol and domain from a URL like https://www.example.com/path. Use a capturing group for the domain.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
https?://([^/]+)
Difficulty: Intermediate

Python is dynamically typed AND strongly typed. JavaScript is dynamically typed AND weakly typed. What is the practical difference for a developer?

Correct Answer:
Difficulty: Basic

In C++, 'A' is a char and "Alice" is a const char* — they are fundamentally different types. A C++ student writes name = 'Alice' in Python and worries they’ve created a character array instead of a string. Are they right?

Correct Answer:
Difficulty: Basic

A C++ programmer writes total = sum(scores) / len(scores) and expects integer division (like C++’s /). They get 85.5 instead of 85. What happened, and how should they get integer division?

Correct Answer:
Difficulty: Intermediate

A student writes a function that opens a file, but forgets to close it. Their C++ instinct says ‘this will leak the file handle.’ Is this concern valid in Python, and what is the recommended solution?

Correct Answer:
Difficulty: Intermediate

A student uses re.findall(r'ERROR', text) to count errors in a log. Their teammate suggests text.count('ERROR') instead. When is re.findall() the better choice?

Correct Answer:
Difficulty: Intermediate

A script needs to report both results (to stdout) and diagnostics (to stderr). A student puts everything in print(). Why is this problematic in a pipeline like python script.py > results.txt?

Correct Answer:
Difficulty: Intermediate

A student writes this list comprehension:

result = [x**2 for x in range(1000000) if x % 2 == 0]

Their teammate says: “This creates a huge list in memory. Use a generator expression instead.” What would the generator version look like, and why is it better?

Correct Answer:
Difficulty: Advanced

Does this code have a bug?

def add_item(item, items=[]):
    items.append(item)
    return items
Correct Answer:
Difficulty: Intermediate

Arrange the lines to define a function that safely reads a file and returns the word count, using with for resource management.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
def count_words(filename):
total = 0
with open(filename) as f:
for line in f:
total += len(line.split())
return total
Difficulty: Intermediate

Arrange the lines to create a list comprehension that filters and transforms data, then prints the result.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
scores = [95, 83, 71, 62, 55]
passing = [s for s in scores if s >= 70]
print(f'Passing scores: {passing}')
Difficulty: Intermediate

A C++ developer argues: ‘Single-threaded means Node.js can only handle one request at a time, so it’s useless for servers.’ What is the flaw in this reasoning?

Correct Answer:
Difficulty: Intermediate

A developer writes this code and is confused why the output is A, C, B instead of A, B, C:

console.log("A");
setTimeout(() => console.log("B"), 0);
console.log("C");

Explain the output using the Event Loop model.

Correct Answer:
Difficulty: Intermediate

A teammate’s code uses == for all comparisons and it ‘works fine in tests.’ You suggest changing to === in code review. They push back: ‘If it works, why change it?’ What is the strongest argument for ===?

Correct Answer:
Difficulty: Intermediate

Compare these two approaches for fetching data from two independent APIs:

Approach A (Sequential):

const users = await fetchUsers();
const posts = await fetchPosts();

Approach B (Parallel):

const [users, posts] = await Promise.all([fetchUsers(), fetchPosts()]);

When should you prefer B over A?

Correct Answer:
Difficulty: Intermediate

A student writes var x = 5 inside a for loop body. After the loop, they access x and are surprised it’s still in scope. A C++ programmer would expect x to be destroyed at the closing brace. What JavaScript concept explains this?

Correct Answer:
Difficulty: Intermediate

Why is the callback pattern fundamental to ALL of Node.js — not just a stylistic choice?

Correct Answer:
Difficulty: Advanced

A student writes:

async function processAll(items) {
    items.forEach(async (item) => {
        await processItem(item);
    });
    console.log("All done!");
}

They expect “All done!” to print after all items are processed. What is the bug?

Correct Answer:
Difficulty: Advanced

Arrange the lines to write an async function that reads a file and returns its parsed JSON content, handling errors gracefully.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
async function loadConfig(path) {
try {
const data = await fs.promises.readFile(path, 'utf-8');
return JSON.parse(data);
} catch (err) {
console.error('Failed to load config:', err.message);
return null;
}
}
Difficulty: Intermediate

Arrange the lines to set up a basic Express.js route handler that reads a query parameter and sends a JSON response.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
const express = require('express');
const app = express();
app.get('/api/greet', (req, res) => {
const name = req.query.name || 'World';
res.json({ message: `Hello, ${name}!` });
});
app.listen(3000);
Difficulty: Intermediate

Arrange the fragments to build a Promise chain that fetches data, parses JSON, and handles errors.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
fetch(url).then(res => res.json()).then(data => console.log(data)).catch(err => console.error(err))
Difficulty: Intermediate

You are building a TikTok-style feed. Match each task to the best array method:

  • Task A: Remove videos the user has already seen
  • Task B: Convert each video object into a <VideoCard> component
  • Task C: Calculate the total watch time across all videos
Correct Answer:
Difficulty: Advanced

A Discord bot fetches a user’s message count from an API. The API returns "42" (a string). The bot checks if (count == 42) to award a badge. What are ALL the problems?

Correct Answer:
Difficulty: Intermediate

Arrange the lines to process an array of Spotify tracks: filter explicit songs, extract just the titles, and join them into a comma-separated string.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
const playlist = tracks .filter(t => !t.explicit) .map(t => t.title) .join(', ');
Difficulty: Intermediate

What does calling an async function always return, even if the function body just returns a plain number like return 42?

Correct Answer:
Difficulty: Advanced

A developer needs a delay(ms) utility that returns a Promise resolving after ms milliseconds. Which implementation is correct?

Correct Answer:
Difficulty: Intermediate

Arrange the lines to filter passing students (grade ≥ 60) and extract just their names.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
const passingNames = students .filter(s => s.grade >= 60) .map(s => s.name);
Difficulty: Advanced

Arrange the lines of a corrected processAll function. The original bug: "All done!" printed before items finished processing because .forEach() ignores the await inside its callback.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
async function processAll(items) {
for (const item of items) {
await processItem(item);
}
console.log("All done!");
}
Difficulty: Advanced

A student writes this code for a multiplayer game server and wonders why player moves are “laggy”:

app.post('/move', (req, res) => {
    // Compute best AI response (CPU-intensive, ~2 seconds)
    const aiMove = computeAIResponse(req.body.board);
    res.json({ move: aiMove });
});

What is wrong, and what would you suggest?

Correct Answer:
Difficulty: Advanced

Arrange the lines to look up a student by ID from a roster array, handle the case where the student isn’t found, and return their data as JSON.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
router.get('/students/:id', async (req, res) => {
const roster = await fetchRoster();
const student = roster.find(s => s.id === Number(req.params.id));
if (!student) { return res.json({ error: 'Not found' }); }
res.json(student);
});
Difficulty: Basic

Arrange the lines to create a JavaScript object, convert it to a JSON string, parse it back, and log a property.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
const student = { name: 'Alice', grade: 95 };
const jsonStr = JSON.stringify(student);
const parsed = JSON.parse(jsonStr);
console.log(parsed.name);
Difficulty: Basic

What is the value of x after this code runs?

let x;
console.log(x);
console.log(typeof x);
Correct Answer:
Difficulty: Advanced

Arrange the lines to safely access a nested property, provide a default, and log the result.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
const user = { profile: { address: null } };const city = user?.profile?.address?.city ?? 'Unknown';console.log(city);
Difficulty: Intermediate

A C++ developer writes this React component and is confused why clicking the button does nothing:

function Counter() {
  let count = 0;
  return <button onClick={() => count++}>{count}</button>;
}

What is the bug, using the React rendering model?

Correct Answer:
Difficulty: Advanced

A student stores the full filtered list in state alongside the unfiltered list: const [allTasks, setAllTasks] = useState(tasks) and const [filteredTasks, setFilteredTasks] = useState(tasks). What design problem does this create?

Correct Answer:
Difficulty: Advanced

Why does React require a stable key prop on list items, and why is using the array index as a key dangerous for dynamic lists?

Correct Answer:
Difficulty: Intermediate

In ‘Thinking in React’, why should you build a static version (props only, no state) BEFORE adding any state?

Correct Answer:
Difficulty: Advanced

What renders when count is 0?

{count && <Badge count={count} />}
Correct Answer:
Difficulty: Intermediate

A <SearchBar> and a <ProductTable> are sibling components. The user types in the search bar and the table should filter. Where should the filterText state live, and why?

Correct Answer:
Difficulty: Advanced

A student proposes using class inheritance for React components: class AdminCard extends UserCard. Why does React prefer composition instead?

Correct Answer:
Difficulty: Advanced

Arrange the lines to build a React component with a controlled input that filters a list of items.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
function FilterList({ items }) {
const [query, setQuery] = useState('');
const filtered = items.filter(item => item.includes(query));
return (
<>
<input value={query} onChange={e => setQuery(e.target.value)} />
<ul>{filtered.map(item => <li key={item}>{item}</li>)}</ul>
</>
);
}
Difficulty: Advanced

Arrange the lines to create a custom React hook that fetches data from an API on mount.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
function useFetch(url) {
const [data, setData] = useState(null);
useEffect(() => {
fetch(url)
.then(res => res.json())
.then(json => setData(json));
}, [url]);
return data;
}
Difficulty: Advanced

Arrange the fragments to write a JSX expression that conditionally renders a badge, avoiding the 0 rendering bug.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
{count > 0&&<Badge count={count} />}
Difficulty: Advanced

What happens when the component first renders?

function App() {
  const [count, setCount] = useState(0);
  return <button onClick={setCount(count + 1)}>{count}</button>;
}
Correct Answer:
Difficulty: Advanced

A component fetches user data based on a userId prop:

useEffect(() => {
  fetch(`/api/users/${userId}`)
    .then(res => res.json())
    .then(data => setUser(data));
}, []);

The parent changes userId from 1 to 2, but the screen still shows user 1. Diagnose the bug.

Correct Answer:
Difficulty: Intermediate

A component tracks a user object: const [user, setUser] = useState({ name: 'Alice', age: 25 }). How should you update only the name to 'Bob' while keeping age intact?

Correct Answer:
Difficulty: Advanced

A student has four bugs in different components. Match each bug to the React concept that fixes it: (a) Product names don’t update when different data is passed in (b) A like counter always shows 0 (c) Deleting the 2nd item in a list causes the 3rd item’s checkbox to jump to the 2nd position (d) A <div class="header"> renders but has no CSS styling

Correct Answer:
Difficulty: Intermediate

Arrange the lines to add an item to a shopping cart stored in React state, using immutable updates.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
const [cart, setCart] = React.useState([]);
const addToCart = (product) => {
setCart(prev => [...prev, product]);
};
Difficulty: Advanced

Arrange the lines to build a counter component that safely increments using the functional update pattern.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
function Counter() {
const [count, setCount] = useState(0);
function handleClick() {
setCount(prev => prev + 1);
}
return (
<div>
<p>Count: {count}</p>
<button onClick={handleClick}>+</button>
</div>
);
}
Difficulty: Advanced

Arrange the lines to build a component that fetches user data when it mounts or when userId changes, and shows a loading message while waiting.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
function UserProfile({ userId }) {
const [user, setUser] = useState(null);
useEffect(() => {
fetch(`/api/users/${userId}`)
.then(res => res.json())
.then(data => setUser(data));
}, [userId]);
if (user === null) {
return <p>Loading...</p>;
}
return <h2>{user.name}</h2>;
}
Difficulty: Basic

Which of the following best describes the core difference between centralized and distributed version control systems (like Git)?

Correct Answer:
Difficulty: Basic

What are the three primary local states that a file can reside in within a standard Git workflow?

Correct Answer:
Difficulty: Intermediate

What does the command git diff HEAD compare?

Correct Answer:
Difficulty: Basic

Which Git command should you NEVER use on a shared branch because it can permanently overwrite and destroy work pushed by other team members?

Correct Answer:
Difficulty: Intermediate

Which of the following are advantages of a Distributed Version Control System (like Git) compared to a Centralized one? (Select all that apply)

Correct Answers:
Difficulty: Basic

Which of the following represent the core local states (or areas) where files can reside in a standard Git architecture? (Select all that apply)

Correct Answers:
Difficulty: Intermediate

Which of the following commands are primarily used to review changes, history, or differences in a Git repository? (Select all that apply)

Correct Answers:
Difficulty: Advanced

A faulty commit was pushed to a shared ‘main’ branch last week and your teammates have already synced it. Why should you use git revert to fix this rather than git reset --hard followed by a force-push?

Correct Answer:
Difficulty: Advanced

When integrating a feature branch into ‘main’, under what condition will Git perform a fast-forward merge rather than creating a three-way merge commit?

Correct Answer:
Difficulty: Advanced

Arrange the Git commands into the correct order to: create a feature branch, make changes, and integrate them back into main via a merge.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
git switch -c feature&&git add app.py&&git commit -m 'Add feature'&&git switch main&&git merge feature
Difficulty: Advanced

Arrange the commands to undo a bad commit on a shared branch safely: first identify the commit, then revert it, then push the fix.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
git log --oneline&&git revert <bad-commit-hash>&&git push
Difficulty: Intermediate

Arrange the commands to initialize a new repository and record an initial commit.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
git init&&git add .&&git commit -m 'Initial commit'
Difficulty: Intermediate

Arrange the commands to register a remote called origin and push the main branch to it for the first time.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
git remote add origin <url>&&git push -u origin main
Difficulty: Intermediate

You have some uncommitted, incomplete changes in your working directory, but you need to switch to another branch to urgently fix a bug. Which command is best suited to temporarily save your current work without making a messy commit?

Correct Answer:
Difficulty: Intermediate

What happens when you enter a ‘Detached HEAD’ state in Git?

Correct Answer:
Difficulty: Intermediate

Which Git command utilizes a binary search through your commit history to help you pinpoint the exact commit that introduced a bug?

Correct Answer:
Difficulty: Intermediate

What is the primary purpose of Git Submodules?

Correct Answer:
Difficulty: Advanced

In which of the following scenarios would using git stash be considered an appropriate and helpful practice? (Select all that apply)

Correct Answers:
Difficulty: Advanced

Which of the following are valid methods or strategies for integrating changes from a feature branch back into the main codebase? (Select all that apply)

Correct Answers:
Difficulty: Advanced

What does the file .git/HEAD contain when you are checked out on a branch, compared to when you are in a detached HEAD state?

Correct Answer:
Difficulty: Advanced

Arrange the commands to safely stash your work, pull remote changes, and restore your stashed work.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
git stash&&git pull&&git stash pop
Difficulty: Advanced

Arrange the commands to stage a forgotten file and fold it into the last commit without changing the commit message.

Drag fragments into the answer area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
git add forgotten.py&&git commit --amend --no-edit
Difficulty: Intermediate

Predict the output of this code:

String a = new String("hello");
String b = new String("hello");
System.out.println(a == b);
System.out.println(a.equals(b));
Correct Answer:
Difficulty: Advanced

What does this code print?

Integer x = 200;
Integer y = 200;
System.out.println(x == y);
System.out.println(x.equals(y));
Correct Answer:
Difficulty: Intermediate

What happens at runtime when this code executes?

Integer count = null;
int n = count;
Correct Answer:
Difficulty: Advanced

A teammate writes this in a hot loop:

Integer sum = 0;
for (int i = 0; i < 1_000_000; i++) {
    sum += i;
}

You suggest changing Integer sum to int sum. What is the precise reason?

Correct Answer:
Difficulty: Advanced

In Java, what is the default access level when no access modifier is specified on a field or method?

Correct Answer:
Difficulty: Advanced

A GradeReport class has private ArrayList<Integer> scores and exposes it like this:

public ArrayList<Integer> getScores() { return scores; }

All fields are private. Has information hiding (Parnas) been achieved?

Correct Answer:
Difficulty: Intermediate

Dog, Car, and Printer each need a serialize() method. They share no fields or common behavior. Which Java construct is the right fit?

Correct Answer:
Difficulty: Advanced

Why is ArrayList<int> illegal in Java, while vector<int> is valid in C++?

Correct Answer:
Difficulty: Advanced

This code does not compile. Why?

public boolean isStringList(List<?> list) {
    return list instanceof List<String>;
}
Correct Answer:
Difficulty: Intermediate

Match each task to the best collection:

  • A: Track which students have submitted homework (no duplicates, O(1) lookup by name)
  • B: Map each student ID (int) to their final grade (double)
  • C: Maintain an ordered history of grade submissions (newest at the end, access by index)
Correct Answer:
Difficulty: Advanced

What is the bug in this code?

Map<String, Integer> scores = new HashMap<>();
scores.put("Alice", 95);
int grade = scores.get("Bob");
Correct Answer:
Difficulty: Basic

Which exceptions does the Java compiler force you to explicitly catch or declare with throws?

Correct Answer:
Difficulty: Advanced

In a Java constructor, where must super(args) appear, and what happens if you omit it?

Correct Answer:
Difficulty: Intermediate

Given:

Vehicle v = new Car("Toyota", 2024, 4);
System.out.println(v.describe());

Vehicle is abstract with abstract describe(). Car overrides it. Which describe() runs?

Correct Answer:
Difficulty: Advanced

Arrange the lines to implement a generic Pair<A, B> class with a static swap method that returns a Pair<B, A>.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
public class Pair<A, B> {
private A first;
private B second;
public Pair(A first, B second) { this.first = first; this.second = second; }
public A getFirst() { return first; }
public B getSecond() { return second; }
public static <X, Y> Pair<Y, X> swap(Pair<X, Y> p) {
return new Pair<>(p.getSecond(), p.getFirst());
}
}
Difficulty: Intermediate

Arrange the lines to define a Shape interface and a Circle class that correctly implements it.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
public interface Shape {
double getArea();
double getPerimeter();
}
public class Circle implements Shape {
private double radius;
public Circle(double radius) { this.radius = radius; }
@Override
public double getArea() { return Math.PI * radius * radius; }
@Override
public double getPerimeter() { return 2 * Math.PI * radius; }
}
Difficulty: Advanced

Arrange the lines to define a checked exception, declare it in a method, and handle it in calling code.

Drag lines into the solution area in the correct order (some items are distractors that should not be used). Keyboard: focus a line and press Space or Enter to move it between the bank and the answer area. Use Arrow Up or Arrow Down to reorder within the answer area.
Correct order:
class InsufficientFundsException extends Exception {
public InsufficientFundsException(String msg) { super(msg); }
}
public boolean withdraw(double amount) throws InsufficientFundsException {
if (amount > balance) { throw new InsufficientFundsException("Insufficient funds"); }
balance -= amount;
return true;
}
try {
account.withdraw(1000.0);
} catch (InsufficientFundsException e) {
System.out.println("Error: " + e.getMessage());
}
Difficulty: Expert

You’re designing a Course class. It needs:

  • A way for other classes to enroll/drop students without knowing the internal storage
  • Fast O(1) lookup for isEnrolled(String name)
  • No duplicate enrollments

Which two decisions together best achieve these goals?

Correct Answer:
Difficulty: Basic

In C, what is the difference between 'a' and "a"?

Correct Answer:
Difficulty: Intermediate

C does not support function overloading. If you want both int and float versions of a print function, what does the standard C convention look like?

Correct Answer:
Difficulty: Intermediate

A C++ programmer wants to translate this swap function to C:

void swap(int& a, int& b) {
    int t = a; a = b; b = t;
}
// call site:
swap(x, y);

What is the correct C version, including the call site?

Correct Answer:
Difficulty: Advanced

A C function int safe_divide(int num, int den, int* result) returns 0 on success and -1 on division by zero. Which call site uses this contract correctly?

Correct Answer:
Difficulty: Advanced

Consider this C code:

int* arr = malloc(10 * sizeof(int));
free(arr);
arr[0] = 42;        // Line A
free(arr);          // Line B

What is the most likely consequence?

Correct Answer:
Difficulty: Intermediate

What is the role of libc (the C standard library) in a typical C program?

Correct Answer:
Difficulty: Advanced

Dijkstra’s note “Go To Statement Considered Harmful” effectively retired goto from mainstream programming, yet the C language still has it and the Linux kernel uses it heavily. Which use of goto is widely accepted in modern C style guides?

Correct Answer:
Difficulty: Expert

NASA’s coding standards for flight software permit C and a restricted subset of C++ — explicitly forbidding exceptions and most polymorphism. What is the strongest pedagogical reason for that restriction?

Correct Answer:
Difficulty: Advanced

Almost every mainstream language can call into a C library — Python, Java, C#, Rust, Go, Ruby — but browser JavaScript cannot directly call C functions on the user’s machine. What is the strongest reason?

Correct Answer:
Difficulty: Advanced

You are shipping a CLI tool that depends on libssl. Compare static and dynamic linking — which statement is correct?

Correct Answer:
Difficulty: Basic

What is the primary mechanism make uses to determine if a target needs to be rebuilt?

Correct Answer:
Difficulty: Basic

What specific whitespace character MUST be used to indent the command/recipe lines in a Makefile rule?

Correct Answer:
Difficulty: Basic

What does the automatic variable $@ represent in a Makefile rule?

Correct Answer:
Difficulty: Intermediate

Why is the .PHONY directive used in Makefiles (e.g., .PHONY: clean)?

Correct Answer:
Difficulty: Intermediate

If a user runs the make command in their terminal without specifying a target, what will make do?

Correct Answer:
Difficulty: Intermediate

You have a pattern rule: %.o: %.c. What does the % symbol do?

Correct Answer:
Difficulty: Intermediate

Which of the following are primary benefits of using a Makefile instead of a standard procedural Bash script (build.sh)? (Select all that apply)

Correct Answers:
Difficulty: Advanced

Which of the following are valid Automatic Variables in Make? (Select all that apply)

Correct Answers:
Difficulty: Advanced

In standard C/C++ project Makefiles, which of the following variables are common conventions used to increase flexibility? (Select all that apply)

Correct Answers:
Difficulty: Advanced

How does the evaluation logic of a Makefile differ from a standard cookbook recipe or procedural script? (Select all that apply)

Correct Answers:

Shell Scripting

Shell Scripting teaches the command line as a composable programming environment: files, processes, redirection, pipes, scripting, exit codes, and regular-expression-powered text processing. The Shell Scripting Tutorial turns those ideas into hands-on practice inside a Linux environment.

Regular Expressions

Regular Expressions covers the pattern language used by tools such as grep, sed, programming-language libraries, and data-cleaning workflows. The basic RegEx tutorial introduces matching and groups, while the advanced RegEx tutorial extends the work to lazy quantifiers and lookarounds.

Python

Python is the scripting and automation language used throughout many SEBook examples, with emphasis on syntax, data structures, functions, modules, and idiomatic problem solving. The Python Essentials Tutorial builds fluency, and the Python Debugging Tutorial practices debugger-driven fault localization.

Node.js

Node.js introduces JavaScript on the server: modules, asynchronous callbacks, event loops, package management, HTTP servers, and Express-style routing. The Node.js Essentials Tutorial gives the same concepts a live coding path.

React

React teaches component-based UI construction: props, state, event handlers, conditional rendering, lists, and the mental model behind one-way data flow. The React Essentials Tutorial practices those ideas in a browser app.

Git

Git explains version control from the everyday commands up through the object model, branching, merging, rebasing, blaming, bisecting, stashing, and submodules. The Git tutorial, Advanced Git tutorial, Visual Git tutorial, and Git playground provide progressively more interactive practice.

Java

Java reviews Java for students coming from C++, Python, or JavaScript, focusing on classes, references, collections, interfaces, exceptions, and static typing. The Java tutorial provides a guided path through those differences.

C Programming

C Programming covers compilation, memory, pointers, arrays, structs, strings, and the places where C deliberately exposes machine-level details. The C for C++ Programmers Tutorial gives a focused warm-up for using C in systems and build-tool exercises.

Make and Makefiles

Makefiles and GNU Make explain dependency-based builds, targets, prerequisites, recipes, variables, automatic variables, and pattern rules. The Make and Makefiles Tutorial practices building and testing small C projects.

Playwright

The Playwright Tutorial teaches end-to-end browser testing for React applications: navigating, interacting, asserting visible behavior, designing strong user-path oracles, and using the Spec Card to plan tests before coding.

UML Tools

The UML Editor, UML Playground, and ArchUML syntax reference support live diagram authoring. The UML Class Diagrams in Python and UML Sequence Diagrams in Python tutorials connect code to diagrams.

Supplemental Tooling

The Spec Card is a fillable planning tool for end-to-end tests. Additional focused tutorials and demos, including SQL, Prolog, and time-travel debugger demos for Python and Node.js, support narrower practice paths when a course or lesson calls for them.