fresher

Fresher interview questions

Spring Boot is an opinionated framework built on top of Spring that removes boilerplate configuration through auto-configuration, starter dependencies and an embedded server, letting you run apps with a single command.

Spring Boot

The JVM runs bytecode, the JRE bundles the JVM plus core libraries needed to run programs, and the JDK adds development tools such as the compiler on top of the JRE.

Java

A class is a blueprint that describes what data and behaviour something has: what properties it holds and what it can do. An object is a real instance created from that blueprint, with its own actual values sitting in memory. For example, a Car class might define colour and speed as properties and a drive method as behaviour, while a specific red car you create with the new keyword is an object built from that plan.

The relationship is one class to many objects. From a single Car class you can create thousands of car objects, each with different colour and speed values, but all of them share the same set of properties and methods defined by the class. This separation between the general design and the many possible instances of it is the foundation of object-oriented programming, and most other Java concepts, such as constructors and inheritance, build on this idea.

Java

Lists are mutable, meaning items can be added, removed or changed after creation, while tuples are immutable once built. Because tuples cannot change, Python can store and access them slightly more efficiently, and they are often used for fixed collections of values, such as coordinates, where changing the contents would not make sense. Lists use square brackets and tuples use parentheses, though the parentheses are optional in many contexts.

Python

JavaScript is a lightweight, interpreted programming language most commonly used to make web pages interactive. It runs natively inside every major browser, handling things like form validation, animations and dynamic content updates. Thanks to Node.js, JavaScript also runs outside the browser, powering servers, command-line tools and even desktop applications, which is a big part of why it has become one of the most widely used languages in the world.

JavaScript

C++ began as an extension of the C language, adding object oriented features such as classes, inheritance, and polymorphism on top of the procedural style C already offered. C keeps you working with plain functions and structures, while C++ lets you group data and the functions that operate on it into a single class. C++ also added templates, exception handling, and a much larger standard library, making it a more expressive language for large, structured applications.

C++

A static member belongs to the class itself rather than to any single object, so there is only ever one copy of it no matter how many objects you create. You can access a static field or method through the class name directly, without creating an object first, and every object that exists shares that same copy. The main method is declared static precisely so the Java Virtual Machine can call it to start the program before any object of that class exists.

A common use for static members is a shared counter or a constant value that every instance should agree on, such as a tax rate or a maximum limit. It is worth being careful with static fields that change, however, since every part of the program reads and writes the same shared value, which can cause subtle bugs if two parts of the code update it at the same time.

Java

A mutable object can have its internal state changed after it is created, while an immutable one cannot. Lists, dictionaries and sets are mutable, so their contents can be updated in place. Numbers, strings, tuples and frozensets are immutable, meaning any "change" actually produces a brand new object rather than modifying the original. This distinction matters most when passing objects into functions or using them as default argument values.

Python

var is function-scoped and can be redeclared and reassigned, but it ignores block boundaries like if statements, which often leads to confusing bugs. let is block-scoped and can be reassigned but not redeclared in the same scope. const is also block-scoped but cannot be reassigned after its initial value is set. Modern JavaScript style favors const by default and let only when a value genuinely needs to change.

JavaScript

A compiler translates an entire program into machine code before anything runs, producing a standalone executable file that the operating system can launch directly. An interpreter instead reads and executes a program line by line, without ever producing a separate binary file. C++ is a compiled language, which is a major reason its programs tend to run faster than those written in purely interpreted languages, since all the translation work happens once, ahead of time, rather than repeatedly during execution.

C++

The == operator checks whether two references point to the exact same object in memory, essentially asking "are these two variables pointing at the identical box." The equals() method, by contrast, checks whether two objects hold the same value, answering "do these two boxes contain the same contents," even if they are different boxes. For primitive types like int, == compares the actual values directly since there is no separate object involved.

This distinction matters most with text. Two separate String objects can contain the exact same characters, "hello" for example, yet == may return false because they are different objects in memory, while equals() correctly returns true because their contents match. As a rule, always use equals() when comparing the value of objects such as String, Integer or a custom class, and reserve == for checking whether two references genuinely point to the same instance.

Java

The equality operator checks whether two objects hold the same value, while is checks whether two variables point to the exact same object in memory. Two separate list objects containing identical items will compare equal but will not be the same object, so is between them returns false. is is normally reserved for comparing against singletons such as None, since value comparisons should almost always use equality instead.

Python

undefined means a variable has been declared but has not yet been given a value, and it is also what a function returns by default when no return statement is written. null is an intentional value that a developer assigns to represent "no value" or "empty" on purpose. In practice, undefined usually signals something was forgotten, while null signals a deliberate absence of a value.

JavaScript

The core built in types include int for whole numbers, double and float for numbers with a decimal point, char for a single character, and bool for a true or false value. Each type reserves a specific amount of memory and supports a particular range of values, so choosing the right one affects both how much memory a program uses and how precise its calculations can be. Text made of multiple characters typically uses the string type from the standard library rather than one of these basic types.

C++

A starter is a curated bundle of related libraries that Spring Boot lets you add with a single dependency line, instead of hunting down every individual library and making sure their versions are compatible with each other. For example, spring-boot-starter-web pulls in the embedded web server, the JSON conversion library and the core Spring MVC pieces needed to build a web application, all tested together as one working set.

Starters exist for almost every common need, including spring-boot-starter-data-jpa for database access, spring-boot-starter-security for authentication, and spring-boot-starter-test for testing tools. Using starters is one of the main reasons a new Spring Boot project can go from an empty folder to a running application in minutes rather than hours, since the tedious work of dependency matching has already been done for you.

Spring Boot

A dictionary is the right choice when values need to be looked up by a meaningful key rather than by position, such as looking up a user's details by their username. A list is better when order matters and items are naturally accessed by their position or iterated in sequence. Dictionaries also offer near constant time lookups regardless of size, which a list cannot match once it grows large and needs a linear search.

Python

JavaScript has seven primitive types: string, number, boolean, undefined, null, symbol and bigint. Primitives are immutable and compared by their actual value rather than by reference, which is different from objects, arrays and functions, all of which are reference types compared by identity rather than content.

JavaScript

int stores whole numbers only, with no fractional part, while float stores numbers that include a decimal component, though with limited precision compared to double. Dividing two int values in C++ produces another whole number, discarding anything after the decimal point, which surprises many newcomers expecting a fractional result. Choosing float or its more precise cousin double becomes necessary whenever a calculation genuinely needs fractional accuracy, such as measurements, prices, or scientific values.

C++

The @RestController annotation marks a class as a web controller whose methods return data directly in the response body, such as JSON or plain text, rather than the name of an HTML page to render. It is actually a shortcut that combines two other annotations, @Controller, which marks the class as a request handler, and @ResponseBody, which tells Spring to write whatever a method returns straight into the response instead of treating it as a view name.

This is the annotation to reach for whenever you are building a REST API meant to be consumed by a mobile app, a JavaScript front end, or another service, since those clients expect structured data back, not a rendered web page. For a traditional server-rendered website instead, plain @Controller returning template names is the right pattern, which is exactly what the Thymeleaf tutorial covers.

Spring Boot

A set is an unordered collection that automatically enforces uniqueness, so adding the same value twice has no visible effect since only one copy is ever kept. Internally it works like a dictionary with only keys and no values, using hashing to check membership quickly. Sets are commonly used to remove duplicates from a list or to test whether an item exists in a collection very fast.

Python

Type coercion is JavaScript automatically converting a value from one type to another when an operation expects a different type, such as turning the number 5 into the string "5" when it is combined with text using the plus operator. This can produce surprising results, like "5" plus 1 becoming "51" instead of 6, which is one reason many teams prefer the strict equality operator over automatic coercion when comparing values.

JavaScript

A declaration tells the compiler that a name exists and states its type, without necessarily reserving memory for it, which matters most for functions and variables shared across multiple files. A definition actually allocates storage for that variable or provides the body of a function. For an ordinary local variable these two things usually happen together on the same line, but the distinction becomes important once a program spans several source files that need to share the same variable or function safely.

C++

The Bootstrap grid system is a layout tool built on a container, rows and up to twelve columns. Content sits inside column elements, and Bootstrap arranges those columns side by side across the row on larger screens, then automatically stacks them into a single column on smaller screens like phones. The twelve-column model gives flexible proportions, since a column spanning six of the twelve units always takes exactly half the row.

What makes the grid genuinely useful is that its behaviour is controlled per screen size using breakpoint classes, such as col-md-6, which only applies once the screen reaches a medium width. Below that width the same element can fall back to full width automatically. This lets one HTML structure serve phones, tablets and desktops without writing separate layouts for each, which is the main reason the grid is the first thing most people learn in Bootstrap.

Bootstrap

The three common approaches are f-strings, the format method and the older percent-style formatting. F-strings, written with an f before the opening quote, let you embed expressions directly inside curly braces and are now the preferred style for their readability and speed. The format method achieves the same result with placeholders filled in afterward, while percent formatting is an older, C-style approach still seen in legacy code.

Python

The == operator compares two values after converting them to a common type if they differ, which can lead to surprising results like 0 == "0" being true. The === operator, known as strict equality, compares both value and type without any conversion, so 0 === "0" is false. Most style guides recommend always using === to avoid coercion-related bugs.

JavaScript

main is the designated starting point of every standalone C++ program; the operating system looks for this specific function and begins execution there once the program is launched. Everything the program does eventually traces back to calls made from inside main, whether directly or through other functions it invokes. It typically returns a whole number back to the operating system, where a zero conventionally signals that the program finished successfully and anything else signals some kind of failure.

C++

A site becomes responsive in Bootstrap mainly by combining the grid with breakpoint-specific classes such as col-md-6 or col-lg-4. Each of these tells the browser how wide a column should be once the screen reaches that particular size and above, so the same markup rearranges itself automatically as the viewport grows or shrinks, without any extra JavaScript.

Beyond the grid, Bootstrap also provides responsive display utilities, like d-none d-md-block, which hide an element on small screens and reveal it from medium screens upward, and responsive spacing classes, like mt-md-4, which change margin or padding only at a chosen breakpoint. Combining the grid for structure with these utility classes for fine adjustments is usually enough to make an ordinary page work comfortably across phones, tablets and desktops.

Bootstrap

*args collects any extra positional arguments passed to a function into a tuple, letting the function accept a variable number of inputs without naming each one. **kwargs does the same for keyword arguments, collecting them into a dictionary of name and value pairs. Both are commonly used when writing a function that needs to pass extra arguments through to another function without knowing in advance what they will be.

Python

A falsy value is one that behaves as false when evaluated in a boolean context, such as an if statement. JavaScript treats false, 0, an empty string, null, undefined and NaN as falsy. Every other value, including non-empty strings, objects and arrays, even an empty array or object, is considered truthy.

JavaScript

A pointer is a variable that stores the memory address of another variable rather than holding a value like a number or piece of text directly. Instead of asking what value is stored here, a pointer answers where is this value actually located in memory. Once you have a pointer to something, you can follow it to read or change the original value indirectly, which is genuinely useful once a program needs to share or modify the same piece of data from more than one place.

C++

An array in Java has a fixed size that is set the moment it is created and can never change afterward; to fit one more item, a new, larger array has to be created and the values copied across. An ArrayList, on the other hand, is a class from the collections framework that grows and shrinks automatically as items are added or removed, and it comes with convenient methods such as add, remove and contains that a plain array does not have.

The trade-off is that arrays are slightly more memory-efficient and can hold primitive types like int directly, while an ArrayList of integers actually stores boxed Integer objects, adding a small amount of overhead. In practice, an array fits best when the number of items is fixed and known upfront, such as the seven days of the week, and an ArrayList fits best whenever the collection might grow, shrink, or the extra convenience methods are useful, which describes most real application code.

Java

self refers to the specific object the method is being called on, letting the method read and update that object's own attributes rather than some other instance of the same class. It is passed automatically by Python whenever a method is called on an object, which is why it must be listed as the first parameter in the method definition even though it is never supplied explicitly by the caller.

Python

The most common ways are a function declaration, written as the function keyword followed by a name, parameters and a body, and a function expression, where a function is assigned to a variable. Function declarations are hoisted and can be called before they appear in the file, while function expressions are not available until the line where they are defined actually runs.

JavaScript

A reference acts as another name for an existing variable rather than a completely separate variable that stores an address. Once created, a reference cannot be made to refer to a different variable later, whereas a pointer can be reassigned to point somewhere else at any time. References also cannot be left unset the way a pointer can be left empty, which generally makes them a little safer and simpler to reason about whenever you do not need a pointer's extra flexibility.

C++

__init__ is the constructor that runs automatically the moment a new object is created from a class, and its usual job is to set up the object's starting attributes based on whatever arguments were passed in. Without it, a newly created object would have no attributes assigned at all, requiring them to be set individually after creation instead of arriving ready to use.

Python

An arrow function is a shorter syntax for writing a function, introduced to make callbacks and short functions easier to write. Beyond the shorter syntax, its key behavioral difference is that it does not have its own this value; instead it inherits this from the surrounding code, which makes it especially useful inside callbacks where the traditional behavior of this would otherwise cause bugs.

JavaScript

Passing by value copies the argument into the function, so any changes made inside the function have no effect on the original variable back where it was called from. Passing by reference instead gives the function direct access to the original variable, so changes made inside genuinely affect it outside as well. Pass by value is the safer default for small values like numbers, while pass by reference avoids unnecessary copying for larger data and is needed whenever a function must modify the caller's variable.

C++

A class variable is defined directly inside the class body and is shared by every instance of that class, so changing it through the class itself affects all objects at once. An instance variable is usually set inside __init__ using self, and each object gets its own independent copy. Confusing the two is a common source of bugs, especially with mutable class variables that unexpectedly end up shared across every instance.

Python

A function declaration starts with the function keyword and a name at the statement level, and it is hoisted, meaning it can be called earlier in the code than where it is written. A function expression assigns a function to a variable, and it only becomes callable once that line of code actually executes, since only the variable declaration itself is hoisted, not the function assigned to it.

JavaScript

Marking a variable const tells the compiler that its value must never change after it is initially set, and any attempt to reassign it later becomes a compile time error rather than a runtime surprise. It can also be applied to function parameters to promise that a function will not modify the data it was given, and to member functions to promise they will not modify the object they belong to. This makes intent explicit and lets the compiler catch accidental changes early.

C++

A class can be defined to inherit from another by listing the parent class in parentheses after the class name, which automatically gives the child class every attribute and method the parent defines. The child can then add new behaviour of its own or override an inherited method by redefining it with the same name, letting related classes share common logic while still customising the parts that differ.

Python

An array is an ordered list of values, which can be of any type and even mixed types, accessed by a numeric index starting at zero. The most common way to create one is with square brackets, such as const numbers equals an opening and closing bracket containing 1, 2, 3, though the Array constructor is also available for less common cases like pre-sizing an array.

JavaScript

A plain array has a fixed size chosen at the moment it is created and cannot grow or shrink afterward, and it does not track its own length, so a separate variable is usually needed alongside it. A vector, part of the standard library, can grow and shrink as items are added or removed, and it always knows its own size internally. Because of this added flexibility and safety, most modern C++ code reaches for a vector by default and only uses a plain array when there is a specific reason to.

C++

super() gives access to methods defined on a parent class from within a child class, most commonly used inside an overridden __init__ to run the parent's setup logic before adding anything specific to the child. This avoids repeating the parent's initialization code and keeps the relationship between the two classes explicit, rather than hardcoding the parent class name directly.

Python

An object is a collection of key-value pairs, where each key is a string or symbol and each value can be any type, including another object or a function. Objects are the primary way JavaScript models real-world entities, and they are typically created with curly-brace literal syntax, such as a user object holding name and age properties.

JavaScript

A class is a user defined blueprint that bundles together data, called member variables, and the functions that operate on that data, called member functions, into a single unit. It describes a general shape for something, such as a bank account or a shape on screen, without yet being an actual instance of it. Classes are the foundation of object oriented programming in C++, letting a program model real world concepts as self contained, reusable pieces of code.

C++

A list comprehension builds a new list in a single, compact expression by looping over an existing iterable and optionally filtering it, instead of writing a separate for loop that appends to an empty list step by step. Beyond being shorter, comprehensions are usually a little faster too, since the looping happens internally rather than through repeated method calls, though very complex logic is often clearer written as a normal loop instead.

Python

Common options include a standard for loop with an index, a for-of loop that iterates directly over each value, and the forEach array method, which calls a given function once for every item. for-of and forEach are generally preferred for readability when the index itself is not needed, while a standard for loop is still useful when finer control is needed, such as skipping items or looping backwards.

JavaScript

An object is a concrete instance created from a class blueprint, occupying its own memory and holding its own particular values for whatever member variables the class defines. Many separate objects can be created from the very same class, each independent of the others, similar to how many individual houses can be built from one architectural plan. Creating an object typically triggers the class's constructor, which sets up that specific object's starting state.

C++

A dictionary comprehension is the same idea as a list comprehension applied to building a dictionary, producing key and value pairs from an iterable in one expression rather than looping and assigning entries one at a time. It is especially handy for transforming an existing dictionary or building a lookup table from two related sequences without several lines of manual looping code.

Python

map creates a brand new array by calling a given function on every item of the original array and collecting the results, without changing the original array at all. It is the standard tool for transforming every element in a list, such as converting an array of prices into an array of prices with tax already added.

JavaScript

A constructor is a special member function that runs automatically the moment an object is created, and its main job is to set the object up with sensible starting values. It shares its name with the class itself and has no return type at all, not even void. A class can define several constructors accepting different sets of arguments, letting an object be created in more than one way depending on what information is available at the time.

C++

Slicing extracts a portion of a sequence using a start position, a stop position and an optional step, separated by colons inside square brackets. Leaving the start or stop empty defaults to the beginning or end of the sequence, and a negative step reverses the direction, which is the common trick behind reversing a string or list in one line. The stop position is never included in the result, only values up to but excluding it.

Python

filter creates a new array containing only the items from the original array for which a given function returns true, leaving the original array untouched. It is the standard way to select a subset of items based on a condition, such as pulling out only the completed tasks from a longer list of tasks.

JavaScript

A destructor is a special member function that runs automatically just before an object is destroyed, whether that happens because it goes out of scope or is explicitly deleted. It is named after the class with a tilde in front, takes no arguments, and is typically used to release any resources the object was holding, such as memory it allocated itself or a file handle it opened, so that nothing is left behind once the object disappears.

C++

append adds a single item to the end of a list exactly as given, so appending another list adds that whole list as one nested element. extend instead adds each item from the given iterable individually, flattening it into the original list one element at a time. Mixing the two up is a common beginner mistake that results in an unexpectedly nested list.

Python

reduce processes every item in an array and combines them into a single accumulated value, using a function that receives the running total and the current item on each pass. It is commonly used to sum numbers, flatten nested arrays, or build up an object from a list, and it is one of the more flexible but also more commonly misunderstood array methods.

JavaScript

A constructor runs at the beginning of an object's life to set it up, and it can accept parameters and be overloaded so several versions exist for different situations. A destructor runs at the very end of an object's life to clean it up, takes no parameters, and a class can only ever have exactly one. In short, one prepares an object for use while the other guarantees it is torn down properly once it is no longer needed.

C++

remove searches for the first matching value and deletes it, raising an error if the value is not present. pop removes and returns the item at a given position, defaulting to the last item if no index is given, which makes it useful when the removed value is still needed. del is a general statement that can remove an item by position, delete a slice, or remove a variable entirely, and it does not return anything.

Python

A template literal is a string written with backticks instead of quotes, allowing variables and expressions to be embedded directly inside the string using a dollar sign and curly braces, and allowing the string to span multiple lines without special characters. It largely replaced manually concatenating strings with the plus operator because it is easier to read and less error-prone.

JavaScript

Function overloading lets a program define several functions that share the same name but differ in the number or types of parameters they accept. When the function is called, the compiler figures out which specific version was intended by comparing the arguments provided against each overload's parameter list. This is useful when an operation conceptually means the same thing regardless of the input type, such as adding two whole numbers versus adding two decimal numbers, without needing separate, differently named functions for each case.

C++

Code that might raise an error is placed inside a try block, and if an exception occurs, control jumps immediately to a matching except block instead of crashing the program. A finally block, if present, always runs afterward regardless of whether an exception was raised or caught, making it the natural place for cleanup work such as closing a file or a network connection.

Python

The DOM, or Document Object Model, is the tree of objects a browser builds to represent every element on a web page after loading the HTML. JavaScript reads and modifies this tree to change what the user sees without reloading the page, which is the mechanism behind everything from updating text to adding brand new elements dynamically.

JavaScript

Yes, a C++ function can specify a default value for one or more of its trailing parameters, and a caller who omits that argument automatically receives the specified default instead. This reduces the need to write several overloaded versions of a function purely to handle optional arguments. Default values must be provided for parameters starting from the right hand side of the parameter list onward, since the compiler needs to unambiguously match whichever arguments are actually supplied.

C++

A custom exception is usually created by defining a new class that inherits from Exception, or from a more specific built-in exception if one fits, and then raising an instance of it with the raise keyword wherever the error condition is detected. This lets calling code catch that specific exception type by name, which communicates the problem far more clearly than raising a generic exception with only a text message.

Python

The most flexible method is querySelector, which accepts any CSS-style selector and returns the first matching element, with querySelectorAll returning every match as a list. Older methods like getElementById and getElementsByClassName still work and can be slightly faster for simple lookups, but querySelector has become the common default because its selector syntax is so familiar from CSS.

JavaScript

The scope resolution operator, written as two colons together, is used to specify exactly which scope a name belongs to when there could otherwise be ambiguity. It commonly appears when defining a class's member function outside the class body, tying that definition back to the correct class, and it is also used to access something inside a namespace, such as reaching a name that belongs to the standard namespace rather than one defined locally in the current file.

C++

None represents the absence of a value and is Python's equivalent of null in other languages, often returned by a function that has nothing meaningful to give back. The correct way to check for it is with is None or is not None rather than an equality comparison, since None is a single unique object and identity comparison is both clearer in intent and marginally faster.

Python

An event listener is a function registered to run automatically whenever a specific event, such as a click or a key press, happens on a particular element. It is attached using the addEventListener method, which takes the event name and the function to run, and it lets a page react to user actions without constantly checking for them.

JavaScript

Members marked public can be accessed from anywhere outside the class, private members can only be accessed from within the class itself, and protected members behave like private ones except that they remain accessible to derived classes that inherit from the class. Choosing the right access level is central to encapsulation, since keeping internal details private while exposing only a clean public interface prevents outside code from depending on, or accidentally breaking, implementation details that might later change.

C++

A local variable is created inside a function and only exists while that function is running, disappearing once it returns. A global variable is defined at the top level of a module and can be read from inside any function without special treatment. To actually assign to a global variable from inside a function, rather than just read it, the function must declare it with the global keyword first, otherwise Python creates a new local variable instead.

Python

event.preventDefault stops the browser's built-in default behavior for a given event, such as a form actually submitting and reloading the page, or a link navigating away. It is commonly called at the start of a submit handler when the form should be processed with JavaScript instead of the browser's normal page-reload behavior.

JavaScript

Inheritance lets one class, called the derived class, reuse the fields and functions already defined by another class, called the base class, without rewriting them from scratch. The derived class automatically gains everything the base class offers and can add its own additional behaviour, or replace some of the inherited behaviour with its own version. This models real world is a relationships well, such as a savings account being a specific kind of bank account that shares most of the same basic behaviour.

C++

pass is a statement that does nothing at all, used purely as a placeholder wherever Python's syntax requires a block of code but nothing needs to happen yet, such as an empty function body or an unfinished branch of an if statement. Without something in that spot, the code would fail to parse at all, since an empty indented block is not valid on its own.

Python

JSON, short for JavaScript Object Notation, is a text-based data format used to exchange data between a client and a server. It looks similar to a JavaScript object literal but is actually just a string, with stricter rules, such as requiring double quotes around every key. A JavaScript object, by contrast, is a live in-memory structure that can hold functions and other objects, which JSON cannot represent directly.

JavaScript

Functionally, struct and class are almost identical in C++, since both can hold data, define functions, and support inheritance. The only real difference is the default access level: members of a struct are public unless stated otherwise, while members of a class are private unless stated otherwise. By convention, many C++ programmers still use struct for simple, data only groupings with little or no behaviour, and reserve class for types that combine data with meaningful behaviour and encapsulation.

C++

break stops the loop entirely and jumps to the first line after it, useful once whatever the loop was searching for has already been found. continue skips only the rest of the current pass through the loop body and moves straight on to the next iteration, without ending the loop as a whole. Mixing the two up is an easy mistake when a loop needs to skip certain items rather than stop altogether.

Python

JSON.parse takes a JSON-formatted string and converts it into a real JavaScript object or array that code can work with directly. The reverse operation, turning a JavaScript object into a JSON string for sending over a network or saving to storage, is done with JSON.stringify.

JavaScript

A header file typically holds declarations, such as function signatures and class definitions, that describe what a piece of code offers without necessarily containing its full implementation. Including a header file lets one source file use classes or functions defined elsewhere without needing to see or recompile their actual implementation every time. This separation between declaration and implementation is central to how larger C++ projects stay organised across many files while still compiling efficiently.

C++

A lambda is a small, unnamed function defined in a single line using the lambda keyword, typically used for a short piece of logic needed only once, such as a custom sort key or a quick condition passed into another function. Unlike a regular function defined with def, a lambda can only contain a single expression and cannot include statements like loops or multiple lines of logic.

Python

typeof returns a string describing the type of a given value, such as "string", "number", "boolean", "undefined", "object" or "function". It is commonly used to check what kind of value a variable holds before operating on it, though it has a well-known quirk where typeof applied to null incorrectly returns "object", a long-standing bug preserved for backward compatibility.

JavaScript

Include guards are a small block of preprocessor directives placed at the top of a header file that prevent its contents from being processed more than once if it happens to be included, directly or indirectly, several times within the same source file. Without them, a header included twice can cause the compiler to see the same class or function declared repeatedly, producing confusing duplicate definition errors. Modern code often uses a single pragma once directive as a simpler, equivalent alternative.

C++

map applies a given function to every item in an iterable and produces a new sequence of the results, while filter keeps only the items for which a given function returns true, discarding the rest. Both achieve what could also be written as a for loop with an if statement or an append call, but they express the intent more compactly, and are often paired with a lambda for the function argument.

Python

NaN stands for "not a number" and represents the result of an invalid or undefined mathematical operation, such as dividing zero by zero or parsing text that is not numeric. Because NaN is famously not equal to itself, checking a value against NaN directly never works; instead, Number.isNaN or the global isNaN function should be used to reliably detect it.

JavaScript

Declaring a function tells the compiler its name, return type, and parameter types, essentially describing its signature so other code can call it before its actual implementation has even been written or compiled yet. Defining a function provides the actual body containing the logic that runs when it is called. Header files typically hold declarations so multiple source files can call a function, while exactly one source file holds its single definition.

C++

PEP 8 is Python's official style guide, describing conventions such as indentation width, naming styles for variables and functions, and how to space out operators and imports. Following it is not enforced by the language itself, but consistent style makes code far easier for other developers, and your future self, to read, and most teams and open-source projects expect contributions to follow it closely.

Python

push adds one or more new items to the end of an array and returns the array's new length, while pop removes the very last item from the array and returns that removed item. Both methods change, or mutate, the original array in place rather than creating a new one.

JavaScript

Stack memory holds ordinary local variables and is managed automatically: as soon as the function that created them finishes, that memory is instantly and safely reclaimed with no extra effort from the programmer. Heap memory is a separate pool that a program can request from at any time, and anything placed there survives until it is explicitly released, or until the program ends. Heap memory offers more flexibility for data that must outlive a single function, but it comes with the added responsibility of eventually freeing it.

C++

Python uses indentation itself as the way to mark where a block of code, such as the body of a function or an if statement, begins and ends, rather than relying on symbols like curly braces. This was a deliberate design choice to force consistently readable code, since the visual structure of the code always matches its actual logical structure, but it also means inconsistent indentation is a syntax error rather than just a style complaint.

Python

The spread operator, written as three dots, expands the elements of an array or the properties of an object into another array, object or function call. It is commonly used to copy an array or object without mutating the original, merge multiple arrays together, or pass a list of values as individual arguments to a function.

JavaScript

The new keyword requests a block of memory from the heap, large enough to hold whatever type is specified, constructs an object there if applicable, and returns a pointer pointing at that freshly allocated memory. Unlike memory for an ordinary local variable, memory obtained through new is not automatically cleaned up when the surrounding function ends; it continues to exist until it is explicitly released, which is exactly the behaviour that makes the heap useful for data that needs to outlive a single function call.

C++

A shallow copy creates a new outer object but still shares references to the same nested objects inside it, so changing a nested list inside a shallow copy also changes it in the original. A deep copy recursively copies every nested object as well, producing a completely independent structure with no shared references at all. The copy module provides both a shallow copy function and a deep copy function for exactly this purpose.

Python

Destructuring is a syntax that lets you unpack values from an array or properties from an object into separate variables in a single, concise statement, rather than accessing each one individually with an index or property name. It is widely used when working with function parameters and with data returned from an API, since it makes the intended shape of the data immediately visible.

JavaScript

The delete keyword releases memory that was previously obtained with new, running the appropriate destructor first if the memory held an object, and then returning that memory back to the system so it can be reused elsewhere. Forgetting to call delete on memory you allocated yourself causes a memory leak, since that space remains reserved for the rest of the program's lifetime even though nothing can reach it any longer. Every call to new should be matched by exactly one corresponding delete.

C++

len() returns the number of items in a collection, working on any built-in type that has a defined length, including strings, lists, tuples, dictionaries and sets. For a string it returns the number of characters, and for a dictionary it returns the number of key and value pairs rather than anything about their contents. Calling it on an object with no defined length raises a type error.

Python

A callback function is a function passed as an argument to another function, intended to be called at a later point, often once some operation like a timer, a network request or an array iteration completes. Callbacks are the original way JavaScript handled asynchronous work before promises and async/await became common, and they still appear throughout the language, including inside array methods like map and forEach.

JavaScript

A null pointer is a pointer that has been deliberately set to point at nothing at all, rather than at any valid piece of memory. It is commonly used to signal that a pointer is not currently usable, such as before it has been assigned a real address, or after the memory it once pointed to has already been released. Attempting to read or write through a null pointer, known as dereferencing it, is a serious error that typically crashes the program immediately.

C++

range() produces a sequence of numbers lazily, generating each value only as it is needed rather than storing every number in memory at once, which makes it extremely memory efficient even for a very large range. A literal list of the same numbers stores every single value up front. In practice range() is almost always used for looping a fixed number of times, and converted to an actual list only if the full sequence is genuinely needed.

Python

try wraps code that might fail, catch runs if an error occurs inside the try block, letting the program handle it gracefully instead of crashing, and finally runs afterward regardless of whether an error happened, making it the natural place for cleanup work such as closing a connection or hiding a loading indicator.

JavaScript

An array index in C++ actually represents an offset, meaning how many elements away from the very first element you want to reach, rather than a position number in the everyday counting sense. The first element sits exactly at the array's starting address, zero elements away from itself, which is why it is indexed with zero. This offset based approach also makes the underlying pointer arithmetic that arrays rely on simpler and more consistent, even though it does take some getting used to for newcomers.

C++

An immutable string cannot be changed after it is created, so any operation that looks like it modifies a string, such as concatenation or replacing a character, actually builds and returns a brand new string object instead. This makes strings safe to share freely without worrying that one part of a program might unexpectedly change a value another part is relying on, though it also means repeatedly building up a large string in a loop can be less efficient than using a list and joining it once at the end.

Python

Scope determines where a variable is accessible within the code. JavaScript has global scope, visible everywhere, function scope, visible only inside the function where it is declared, and, since let and const were introduced, block scope, visible only inside the nearest pair of curly braces such as an if statement or loop.

JavaScript

The standard string type manages its own memory automatically, can grow or shrink as needed, and provides many convenient built in operations such as concatenation, searching, and comparison. A plain character array has a fixed size decided at creation time, requires a special terminating character to mark where the text ends, and offers none of those convenience operations directly. Modern C++ code almost always prefers the string type unless there is a specific low level reason to work with raw character arrays instead.

C++

Python caches small integers and some short strings internally for efficiency, so two separate variables holding the same small value may happen to point to the identical cached object, making is return true by coincidence. This behaviour is an implementation detail, not a guarantee, and larger numbers or dynamically built strings will not be cached the same way, so relying on is for value comparison is fragile and should always be avoided in favour of equality.

Python

A variable in global scope is declared outside any function and can be accessed from anywhere in the program, including inside every function. A variable in local scope is declared inside a function or block and can only be accessed within that function or block, which helps prevent different parts of a program from accidentally interfering with each other's data.

JavaScript

A while loop checks its condition before running the loop body, so if the condition is false right from the start, the body never executes even once. A do while loop checks its condition after running the body, guaranteeing that the body always executes at least one time regardless of the condition. This makes do while a natural fit for situations like prompting a user for input, where you want to ask at least once before deciding whether to ask again.

C++

The recommended pattern is a with block using open(), which guarantees the file is closed automatically once the block finishes, even if an error occurs while reading it. Without the with block, the file would need to be closed manually, and forgetting to do so is a common source of bugs, particularly on systems where an open file can block other programs from accessing it.

Python

Hoisting is JavaScript's behavior of moving variable and function declarations to the top of their containing scope before the code actually runs. Function declarations are fully hoisted and callable immediately, var declarations are hoisted but initialized as undefined until their line runs, and let and const are hoisted but remain inaccessible until their declaration line, a state known as the temporal dead zone.

JavaScript

break immediately exits the loop entirely, skipping any remaining iterations and moving execution to whatever comes right after the loop. continue instead skips only the rest of the current iteration and jumps straight to the loop's next check or increment step, allowing the loop to keep going. break is typically used once a search has already found what it needed, while continue is used to skip handling for certain values without abandoning the whole loop.

C++

A module is simply a single Python file containing definitions and code that can be imported elsewhere. A package is a folder containing multiple related modules, along with a special init file that marks it as a package, letting a larger project organise many modules under one importable namespace. In short, a package is a collection of modules grouped together, while a module is the individual file itself.

Python

The ternary operator is a compact, one-line alternative to a simple if-else statement, written as a condition followed by a question mark, a value to use if the condition is true, a colon, and a value to use if it is false. It is best reserved for short, simple decisions, since chaining several together quickly becomes difficult to read.

JavaScript

Operator overloading lets a programmer define what a familiar symbol, such as the plus sign, means when applied to objects of a custom class, rather than only the built in numeric types. For example, a class representing a point in two dimensional space could overload the plus sign so that adding two point objects together produces a new point with combined coordinates, making the code that uses the class read naturally, much like ordinary arithmetic on numbers.

C++

Importing a whole module keeps every name inside it accessible only through the module's own name, which avoids naming clashes but requires typing the module name each time something inside it is used. Importing specific names directly brings just those names into the current file, letting them be used without a prefix, which is more convenient but riskier if two different modules happen to define something with the same name.

Python

forEach runs a given function once for every item in an array purely for its side effects, such as logging each value, and it always returns undefined. map also runs a function on every item but collects the return values into a brand new array. Use forEach when you just need to do something with each item, and map when a transformed array needs to be returned.

JavaScript

A friend function is a function that is not a member of a class but is still granted access to that class's private and protected members, because the class explicitly declares it as a friend. This is occasionally useful when an operation naturally involves two classes equally and does not belong more to one than the other, such as comparing two different types together. Friend access should be used sparingly, since it deliberately breaks the usual encapsulation boundary a class provides.

C++

The core built-in types cover numbers such as integers and floating point values, text through strings, and several ways of grouping data: lists and tuples for ordered sequences, dictionaries for key and value pairs, and sets for unique unordered collections, alongside the boolean type for true and false values. Almost every Python program is built from some combination of these handful of fundamental types.

Python

includes checks whether an array contains a specific value and returns true or false accordingly, without needing to write a manual loop or a separate indexOf check. It also correctly detects NaN as present in an array, unlike the older indexOf method, which cannot find NaN because of how NaN compares to itself.

JavaScript

An object created directly as a local variable lives on the stack and is destroyed automatically the instant the function it was created in returns, with no extra work required. An object created with the new keyword lives on the heap and continues to exist, taking up memory, until it is explicitly deleted, potentially long after the function that created it has already finished. Stack objects are simpler and safer by default, while heap objects offer more control over exactly how long something lives.

C++

Type casting converts a value from one type to another, such as turning the text a user typed into an actual number before doing arithmetic with it. It is done by calling the target type as a function on the value, for example wrapping a string in int() or float(), and it raises an error if the value cannot sensibly be converted, such as trying to turn the word "hello" into a number.

Python

String interpolation is the ability to embed variables or expressions directly inside a string, rather than manually joining separate pieces of text with the plus operator. In JavaScript this is done with template literals, using backticks and placing the expression inside a dollar sign followed by curly braces.

JavaScript

Call by value copies the actual argument into the function's parameter, so changes made inside only affect that local copy and never the original variable. Call by pointer instead passes the memory address of the original variable, letting the function follow that address to read or modify the original value directly. Call by pointer requires explicitly dereferencing the pointer to reach the underlying value, which is one reason many modern C++ programmers prefer references for this same purpose when a pointer's extra flexibility is not required.

C++

A docstring is a string literal placed as the very first statement inside a function, class or module, describing what it does, and unlike a regular comment it is stored as part of the object itself and can be retrieved at runtime with the help function or a tool's documentation generator. Writing a clear docstring is one of the simplest habits that makes a codebase noticeably easier for other people, or a future version of yourself, to understand.

Python

An anonymous function is a function defined without a name, typically written inline as an argument to another function, such as inside an event listener or an array method like map. Anonymous functions keep short, one-off pieces of logic close to where they are used, though a named function can still be preferable when the logic is reused or when a clearer stack trace is useful for debugging.

JavaScript

The sizeof operator reports how much memory, measured in bytes, a particular type or variable occupies, and it is evaluated by the compiler rather than at runtime whenever possible. It is commonly used to calculate how many elements fit in a fixed size array, to help allocate the correct amount of raw memory, or simply out of curiosity about how a given type is represented internally. Its exact result can vary between different compilers and target platforms, so it should never be assumed to be a fixed universal number.

C++

A function is a standalone block of reusable code defined independently, called by its own name. A method is essentially the same idea but defined inside a class and called on an object of that class, automatically receiving that object as its first argument through self. Every method is technically a function, but not every function is a method, since plain functions are not tied to any particular class.

Python

window is the global object provided by the browser, representing the browser tab or window itself. It holds global functions and values like setTimeout, alert and location, and in a browser environment, any variable declared globally with var effectively becomes a property of window, though this does not apply to variables declared with let or const.

JavaScript

A namespace is a named region that groups related names, such as classes and functions, together under one label, preventing naming clashes between code written by different authors or different libraries. Two functions with the exact same name can coexist peacefully as long as they live inside different namespaces, since the namespace becomes part of how that name is uniquely identified. This becomes especially valuable in larger projects that combine code from several different libraries, each of which might otherwise choose overlapping names.

C++

A function with no return statement, or one that reaches the end of its body without hitting a return, automatically hands back None to whoever called it. This surprises beginners fairly often, since calling such a function and trying to use its result usually leads to confusing errors later on, when the code assumes it received a real value but actually received nothing at all.

Python

localStorage is a simple key-value store built into the browser that lets a web page save small amounts of text data on the user's device, persisting even after the browser is closed and reopened. It is commonly used for things like remembering a user's theme preference or saving a draft of a form, though it is not suitable for large amounts of data or sensitive information like passwords.

JavaScript

std is the namespace that holds essentially the entire C++ standard library, including familiar tools like the string type, the vector container, and the input and output streams used for printing to the console. Referring to something like the string type by its full name means explicitly qualifying it with the std namespace in front, though many programs bring the whole namespace into scope at once for convenience, a habit that is generally discouraged in larger codebases because it increases the risk of naming collisions.

C++

A function can return several values at once by separating them with commas after the return keyword, which Python automatically packages into a tuple behind the scenes. The caller can then either treat the result as a single tuple or immediately unpack it into separate variables in one line, which is the far more common and readable pattern seen in real code.

Python

An array is an ordered collection of values indexed by number, best suited to lists where position and order matter. An object is a collection of key-value pairs indexed by name, best suited to describing a single entity with named properties, such as a user with a name and an age. The right choice usually comes down to whether the data is thought of in terms of positions or in terms of named fields.

JavaScript

A local variable is declared inside a function or block and only exists, and is only visible, while that function or block is executing, after which it is automatically destroyed. A global variable is declared outside every function, exists for the entire lifetime of the program, and can potentially be accessed and modified from anywhere in the code. Relying heavily on global variables generally makes a program harder to reason about, since any part of the code could be silently changing shared state.

C++

Unpacking assigns the individual elements of a list, tuple or other iterable directly to separate variables in a single statement, instead of accessing each item by its position one at a time. An asterisk can also be used to capture any remaining items into a single list while unpacking the rest normally, which is handy when only the first item or two actually matter and the rest can be gathered together.

Python

A new property can be added simply by assigning a value to it using dot notation, such as user.city set to "London", or using square bracket notation, such as user["city"] set to "London", which also allows the property name to come from a variable. Both approaches add the property immediately if it does not already exist, or overwrite it if it does.

JavaScript

Recursion is a technique where a function calls itself, either directly or indirectly, in order to break a problem down into smaller versions of the exact same problem until it reaches a simple case that can be answered directly, known as the base case. A classic example is calculating a factorial, where the factorial of a number is defined in terms of the factorial of a smaller number. Every recursive function needs a clearly reachable base case, or it will keep calling itself indefinitely and eventually crash the program.

C++

enumerate() wraps an iterable and produces pairs of a running index alongside each item, letting a for loop access both the position and the value at the same time without manually creating and incrementing a counter variable. It reads more cleanly than tracking an index by hand, and it is the idiomatic way to write this kind of loop in Python.

Python

Array.isArray reliably checks whether a given value is genuinely an array, returning true or false. It exists because typeof applied to an array unhelpfully returns "object", the same result it gives for a plain object, so Array.isArray is the correct and dependable way to distinguish an array from other object-like values.

JavaScript

The return statement immediately ends execution of the current function and, if the function has a non void return type, hands a value back to whatever code called it. Once a return statement runs, no further lines inside that function execute, even if there is more code written below it. A function declared to return void can still use a bare return statement with no value, simply to exit early without producing a result.

C++

zip() takes two or more iterables and combines them element by element into pairs, or larger tuples for more than two iterables, stopping as soon as the shortest one runs out of items. It is commonly used to loop over two related lists at the same time, such as a list of names alongside a matching list of ages, without manually indexing into both.

Python

A default parameter lets a function specify a fallback value to use for a parameter when the caller does not provide one, written directly in the function signature with an equals sign. This avoids the older pattern of manually checking whether an argument was undefined and assigning a fallback value inside the function body.

JavaScript

Type casting is the process of explicitly converting a value from one type to another, such as turning a decimal number into a whole number, or treating one kind of pointer as another. C++ offers several distinct casting operators, including static cast for straightforward, generally safe conversions and reinterpret cast for low level, potentially unsafe reinterpretations of memory, giving programmers finer control and more safety than the older, less specific style of casting inherited from C.

C++

Python's conditional expression lets a value be chosen based on a condition in a single line, written as one value if the condition holds else another value, rather than spreading a full if and else block across several lines just to pick between two options. It is best kept for short, simple choices, since chaining several of them together quickly becomes far harder to read than an ordinary if statement.

Python

Strict mode, enabled with the string "use strict" at the top of a file or function, changes JavaScript to catch common mistakes as actual errors rather than silently allowing them, such as assigning to an undeclared variable or duplicating a parameter name. It also disables some confusing legacy behaviors, and code written as an ES module or inside a class runs in strict mode automatically.

JavaScript

An implicit conversion happens automatically, without the programmer writing anything special, such as when an integer is used somewhere a decimal number is expected and the compiler quietly promotes it. An explicit conversion requires the programmer to deliberately request the conversion using a cast, making the intent clear in the code itself. Explicit conversions are generally considered safer for anything beyond a very obvious, lossless conversion, since they force a programmer to consciously acknowledge that a conversion, and any potential loss of information, is happening.

C++