Software Development

Top Programming Interview Questions You Need to Know

Are you preparing for your next programming interview—or perhaps your first ever? If so, you’re on track for a role in a field that’s in very high demand right now. Programming and coding are vital for making positive disruptions in every industry on earth. It all begins with people like you, working behind the scenes, to ensure digital infrastructure, operating systems, and industrial applications work as they should.

The following 50-plus programming interview questions should give you an idea of the kind of dialogue you can expect with a hiring manager or recruiter in the programming field. Data structures are just the beginning—you may also be asked any number of things, including questions about solving logic problems using coding languages.

With the preamble out of the way, let’s dive in—starting with some of the most basic interview questions any professional will be familiar with.

What Kind of Questions Could You Be Asked?

1. Culture and Fit

You’re probably no stranger to job interviews—or the icebreaker “cultural fit” questions. In a programming interview, some of the questions in this category might be asked in a more specific way. You may be asked to describe your workflow, discuss your approach to working with teams, or comment on how you stay organized during coding projects. For instance:

  • Which programming language did you learn first?
  • Do you carry any current certifications?
  • What kind of related skills have you had to pick up along the way?
  • How do you stay organized during complex projects, and in general?
  • How do you keep your skills and knowledge of this industry current?

You’ll have familiarized yourself with the job requirements by now, so questions about your educational background and experience shouldn’t feel out of left field. Technology companies all over the world are reevaluating their job requirements in light of the ongoing coding and computer sciences talent shortage. If you’re interviewing with such a company, you’ll be asked about, and then have to prove, your willingness to self-start and engage actively in ongoing learning in order to keep your skills relevant.

Nevertheless, there are some fundamentals that every programming interviewee has to know. To help you prepare, our programming interview questions are helpfully organized into 10 fairly broad categories. It’s possible not all of them will be relevant to the position you’re pursuing.

Will you be asked all these questions? Absolutely not! However, before you can know whether a career as a programmer is right for you, you need to know the breadth of the subject matter you’ll be responsible for. Let’s dive in.

2. General Programming and Design Questions

Programming job applicants who don’t know these coding fundamentals won’t be getting a callback. See how many of these questions you can answer in a row without slowing down.

What are variables?

Without variables, you don’t have a program. Variables are values that change within a program, based on the overall conditions and the “work” the program is doing. Variables are values stored or “declared” within the program and represent the working data set for the program. Variables = data sets + algorithms.

What is inheritance?

Inheritance is the basis of object-oriented programming. It provides the ability to extend existing code to meet new requirements without rewriting the code from the ground up.

What is polymorphism?

Polymorphism allows new objects in programming to assume the properties of existing objects. The object providing the inherited characteristics is known as a “base class” or “superclass.”

This is a program’s ability to process an object differently, according to its type or class. Picture a car versus a tank. Polymorphism would be a system that provides a blueprint for the systems they have in common and works across both types of vehicle.

What are pointers?

Pointers contain memory addresses for other values. Manipulating pointers can save time versus manipulating the data the pointers refer to. This can be an efficient way to write programs that manipulate data.

Pointers are used often in C, but less so in Java.

Name four types of storage classes.

Register, static, external, and automatic.

  • Register: These are storage classes kept in the register of the central processing unit.
  • Static: This is a storage class in which the variable does not change. It is declared at the beginning stages of the programming task.
  • External: A storage class local to a piece of hardware, such as device drivers. These say to the compiler: “If I need this variable again, read it from the external device for the most current value.”
  • Automatic: A storage class in which blocks or functions define local variables.

What is encapsulation?

This is one of the most important concepts in object-oriented design. It involves bundling together a class with a set of instructions. In encapsulation, an object includes not just its data but also functions that can mutate that data. Encapsulation may be used to hide the nature of the data while still facilitating interaction.

Name seven data types.

Floating point, integer, string, float, real, character, and Boolean.

Name five data structure types.

Linked lists, files, stacks, queues, trees, and graphs.

What is the difference between a “declaration” and a “definition” of a particular function or variable?

A declaration involves the type and function of an identifier and describes what the linker requires to reference it. A definition describes what the compiler needs to do to interact with the identifier. Sometimes a declaration provides an initial value, and sometimes the definition provides the value.

What is the difference between an interpreter and a compiler?

An interpreter executes commands directly, while a compiler converts those commands (the program) from source code to machine code. Compiled programs run faster than interpretive languages and can be used at scale.

  • Interpretive language examples: Basic, Korn Shell, Ruby, Python
  • Compiler language examples: Java, C++

What are the functions of object-oriented design?

Encapsulation, polymorphism, inheritance, and abstraction.

What is a real-time operating system?

A real-time operating system (OS) processes data as it becomes available, without a buffering period.

  • Example of a real-time OS: Controlling factory machinery in real-time. Not necessarily instant, but essentially on-demand.
  • Examples of non-real-time OS: Windows and macOS. Response time is not as important.

Ready to move on? From here, you can expect the company’s hiring manager to start digging into some of the more specialized knowledge a coder will need.

3. Algorithms

Algorithms are often the bread and butter of a coding professional’s career. You know them as the recipe that powers how data is gathered, sorted, and ultimately made useful in other processes. You can expect algorithm-related questions such as:

Name four kinds of sort algorithms?

Quicksort, insertion sort, selection sort, and bubble sort.

How does a bucket sort algorithm work?

A bucket sort creates an empty array and places each object in a bucket. Each bucket is sorted in order, and then each object returns to the original array.

How does a radix sort algorithm work?

Radix sorting allows you to arrange data using integer keys rather than values. Each piece of data is grouped by digits that have the same value and significant position. In other words, radix sorting is useful for sorting numbers according to their individual digits. Each digit in a number is a key. It may use a counting sort or a bucket sort.

What is a counting sort algorithm, and when is it useful?

A counting sort algorithm counts the instances of each data point and arranges them accordingly. It’s most useful in arrays with relatively few unique values. It can be used to find most-used values, least-used values, unique values, etc.

4. Databases

Coding for databases might involve using languages such as Python, Java, and C# to build and implement web-based, cloud-based, and mobile applications that individuals and organizations can use to interact with collections of information. Not every programming career will require expertise in database management systems, but it doesn’t hurt to get acquainted with some of the major concepts.

Define the word “database.” What kind of interactions does a database management system provide?

A database is any electronic system that contains data and allows it to be used, accessed, updated, and processed.

Database management systems (DBMS) allow administrators, applications, software, and end users to interact with the data stored on the database.

How do database management systems improve on the functionality of file-based systems?

A file-based system may be interacted with directly by users, but not necessarily concurrently. Data-based management provides mediation between the file system and the application programming interfaces (APIs) being used and is more likely to facilitate multiple users at once. However, these users cannot change the same data at the same time.

What are the three main types of database technology?

  • Structure/data: Useful when writing a program that needs to store, manipulate, or read data—but where a full database implementation is not desirable.
  • Navigational: Navigational databases are associated with hierarchical or network models. This describes a database where objects are processed iteratively, one by one.
  • SQL/relational: This stands for “structured query language.” Used to retrieve or update information in a database.

What is normalization used for?

Normalization reorganizes data to eliminate redundancy and save disk space. It does so by creating multiple tables and outlining the relationships between them.

What is the difference between DDL and DML?

DDL stands for “data definition language.” It specifies the structure of a database. DML stands for “data manipulation language” and refers to how data is to be retrieved or modified from said database.

Why is database partitioning necessary?

Partitioning improves efficiency and data availability and minimizes data loss by creating separate, more stable, and more available separate filesystems. Partitioning allows for parallel processing or separating partitions that need to be accessed more or less often.

What is an entity—and what is an entity set?

An entity is a discrete object or data point, such as a person or place. An entity set groups entities of the same type.

5. Arrays

In Java, an entity is an instance of a class. For example: Class = “car.” Instance/entity = “Cadillac CTS.”

Arrays are the most common data structure in programming—and a vital component in determining how information is accessed. If you have variables as the fundamental building blocks, arrays are the next step up.

Problem-solving with arrays.

Let’s see how well you know how to put arrays to work and how to solve some basic problems:

  • How would you check whether an array contains only digits?
  • How would you go about finding all the permutations of a given array?
  • Find a missing number in an array (1-100) of integers.
  • In an array of integers, find the duplicated number.
  • How do you find duplicate numbers in an array that contains multiple duplicates?
  • Given an unsorted array of integers, find the largest and smallest values.
  • Find every pair of integers in an array that when added together, equal a given value.

6. Trees

The following three categories—trees, graphs, and lists—are similar in some fundamental ways, but they still require some specialized knowledge that you might have to call upon during your interview. How well do you know your way around linear and nonlinear data structures?

In Java, trees contain packages that describe how to manipulate lists.

What is a binary search tree, and what is it used for?

A binary tree is a data structure that has two “children” and facilitates the study of data that bifurcates.

Name five types of trees.

Binary trees, binary search trees, AVL trees, B-trees, B+ trees.

Problem-solving with trees:

  • How would you go about mirroring a binary tree?
  • How do you count a number of leaf nodes in a given binary tree?
  • How would you check whether a tree is balanced or not?

7. Graphs

Graphs are nonlinear data structures composed of multiple nodes and edges, or “vertices.” Graphs can represent networking architecture and can be deployed to solve practical problems. Broadly, they describe directed or undirected relationships.

What is depth-first search, or traversal, for graphs?

Depth-first search (DFS) searches graphs and trees by beginning at the root node and following each branch as far as it can before it backtracks. DFS may be used to detect cycles in a graph, to find a path, and to locate strongly connected components.

What is a breadth-first traversal for graphs?

Breadth-first traversal (BFS) examines sibling nodes first and children nodes second. BFS may be used in peer-to-peer networking for finding the shortest path and even in web crawlers used in search engines.

Problem-solving with graphs:

Given a particular graph, how would you determine whether or not it cycles?

8. Lists

Lists are data structures that can be unordered or ordered. Lists can contain objects, strings, and integers. Any type of data may be listed. Each piece of data has a pointer to the next one in the list.

Problem-solving with lists:

  • How do you check if a given linked list contains a cycle? How do you find the starting node of the cycle?
  • How do you reverse a linked list?
  • How do you find the length of a singly linked list?
  • How do you remove duplicate nodes in an unsorted linked list?
  • Using Stack, how do you find the sum of two linked lists?

9. Networking

Networking isn’t remotely a new concept. However, as more of our technologies and industries grow connected with one another and 5G networks and the “internet of things” expand to encompass billions of devices, it couldn’t hurt for programming job-seekers to refamiliarize themselves with networking basics.

What’s the difference between LAN, WAN, and VLAN?

LAN stands for “local area network” and describes a high-speed network of devices in the same location.

WAN stands for “wide area network” and describes a network that is not bound by geography or that dials out to another location. A WAN can be public or private.

VLAN stands for “virtual LAN” (LAN within a LAN) that limits the number of participants but is subdivided to allow communication between known entities.

What are the differences between the OSI and TCP/IP models?

OSI uses a bottom-up approach to data transfer, while TCP/IP uses top-to-bottom data transfer. OSI has seven layers, while TCP/IP has just four. OSI is not tangible, whereas TCP/IP is tangible.

What is DDoS?

DDoS stands for “distributed denial-of-service.” It is a type of attack in which outside systems overwhelm the bandwidth of a targeted system. It’s intended to render the target services unavailable.

It is often referred to as the means whereby hackers attempt to steal information, but this is not wholly accurate.

Define QoS?

QoS stands for “quality of service.” This is a set of technologies that reduce network latency and jitter—and improve service reliability by limiting the number of lost packets. Among other things, it sets priorities for data transfers.

QoS is more important than ever. If a program doesn’t need instantaneous access to the network, it receives a lower QoS score. Programs requiring low latency with other databases receive a higher QoS score.

10. Problem-Solving Using Programming

Some programming interviews will build to some kind of practical, hands-on, or problem-solving demonstration to see how well you can improvise and bring together the major and minor programming concepts. Remember that the most important underlying skill for any type of programmer is the ability to think logically.

Here’s an example of a problem involving random selection:

If you had an array of 52 numbers, such as a deck of cards, it would be easy to choose one at random. Your task is to generate a number between 1 and 52 and use that as the index to your array. In other words, derive a system whereby a number or card is chosen at random from a set or deck with all numbers or cards equally probable.

Here’s a more difficult variation:

Imagine you can neither see the whole set at once nor store it. In other words, you’re not told how many total numbers there will be, and you are shown only one number at a time. You cannot store all the numbers you are shown, and you are only told when you’ve seen the final number of the set.

If you are allowed to store two numbers at most, can you respond with a random number, chosen in an equiprobable manner, from that one-at-a-time set or stream immediately upon being told the stream is complete?

Here’s how to solve this problem:

You need store only two numbers: the total count of numbers seen so far, and your current candidate response, selected from the number stream if it were to end at that point.

When you are shown the first number, you have a count of one. Therefore, your candidate response must be the first and only number seen—it has a probability of one out of one. If you are shown a second number, it becomes your new candidate response with a probability of one out of two. Likewise, a third number will become the new candidate response with a probability of one out of three, and so on.

Thus, as each new number is seen, generate a random number between one and the number of data points seen to that point (N). If your random number is equal to N, then keep the number you were just presented with as your new possible response. Otherwise, keep the answer previously saved through this same logic.

You perform this selection update each time you see a new data point. When you are told the stream is done, the saved value is the right response, chosen equiprobably from all the numbers seen. The probability is 1 out of N regardless of how many there were before the stream stopped.

Here are some other problems to work through:

  • Write an algorithm to find each instance of a given word in a selection of text.
  • Write a program to generate a random number from within a given range.
  • How do you check if a string contains only digits?
  • Given two strings of characters, find the minimum number of changes required to convert string 1 to string 2.
  • How do you count a number of vowels and consonants in a given string?
  • Given a grid where each square has a numerical value, how would you code a solution for finding the lowest-value route from one side of the grid to the other?

Feeling Prepared for Your Programming Interview?

Hopefully, you feel ready to nail the interview and land that programming job you’ve been dreaming of. If not, you’d be amazed by the quality of some of the guides, tutorials, study materials, and full coding courses available online—including at Codeforces, SphereOnline, HackerRank, and elsewhere.

You have what you need to break into this exciting field—and all the motivation in the world, given the importance of, and demand for, innovation in robotics, machine learning, wireless networking, and much more.

Hopefully this broad overview of the major programming concepts has whet your whistle for this exciting career track. What are you waiting for?

Published on Java Code Geeks with permission by
Nathan Sykes, partner at our JCG program. See the original article here: Top Programming Interview Questions You Need to Know

Opinions expressed by Java Code Geeks contributors are their own.

Nathan Sykes

Nathan Sykes is a business and tech writer from Pittsburgh, PA. When he’s not thinking about IoT and cloud computing you can find him watching the Pittsburgh Penguins. To read more posts by Nathan, check out his blog, Finding an Outlet, or follow him on Twitter @nathansykestech.
Subscribe
Notify of
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
Back to top button