InterviewPitch
Ada interview questions

Ada Interview Questions with Answers

Most Asked Ada Interview Questions for Software Engineer Roles

100+ QuestionsDetailed AnswersCode ExamplesUpdated for 2026

Introduction

Ada is a structured, statically typed, high‑level programming language designed for reliability, safety, and maintainability. Originally developed for the U.S. Department of Defense, it is now widely used in aerospace, defence, railway, medical devices, and other safety‑critical systems where correctness and predictability are paramount. This comprehensive guide collects the most frequently asked Ada interview questions – from fundamental concepts like packages, tasks, and strong typing to advanced topics such as the Ravenscar profile, SPARK formal verification, contract‑based programming, and real‑time concurrency. Whether you are a student, an embedded developer, or preparing for a specialised role, these questions will help you deepen your understanding and succeed in your next interview.

Why Ada?

  • Safety‑critical – designed for reliability and formal verification
  • Strong static typing – catches errors at compile time
  • Built‑in concurrency – tasks, protected objects, rendezvous
  • Real‑time support – precise scheduling, priority handling
  • SPARK integration – formal verification of correctness
  • Widely used in aerospace, defence, and industrial systems

Most Asked Ada Interview Questions

Beginner
1. What is Ada?

Ada is a structured, statically typed, high-level programming language designed for reliability and safety-critical systems. It features built-in support for design-by-contract, strong typing, and concurrent real-time execution.

Ada
with Ada.Text_IO; use Ada.Text_IO;

procedure Main is
begin
   Put_Line("Hello, World!");
end Main;
Beginner
2. Who developed Ada?

Ada was developed by the U.S. Department of Defense (DoD) in the late 1970s to replace the hundreds of disparate programming languages then in use within military systems. It was named after Ada Lovelace, often credited as the first computer programmer.

Beginner
3. Why is Ada used in safety‑critical systems?

Because of its uncompromising features: strong static typing, compile‑time checks,safe pointer interfaces, and built‑in concurrency support. It heavily minimises the occurrence of runtime system vulnerabilities, crashes, and undefined behaviours.

Beginner
4. What is strong typing in Ada?

Strong typing in Ada means the compiler enforces strict differentiation between types. For example, you cannot accidentally add an integer measuring Speed to an integer measuring Distancewithout explicit conversions, preventing logical programming mistakes.

Beginner
5. What is a package in Ada?

A package is the fundamental modular unit in Ada used for grouping logically related declarations and implementations together. It consists of a specification file (interface) and a body file (implementation), ensuring clean encapsulation.

Beginner
6. What is a procedure in Ada?

A procedure is a subprogram in Ada that executes an action but does not return a value. It can communicate inputs and outputs to calling blocks using parameters marked with modes: in,out, or in out.

Beginner
7. What is a function in Ada?

A function is a subprogram in Ada that performs computations and must return a single value of a specified type using a return statement.

Beginner
8. What is a variable declaration example?

In Ada, variables are declared using the pattern: Variable_Name : Type_Name := Initial_Value;

Ada
-- Declaration
X : Integer := 10;
Beginner
9. What is a constant in Ada?

Constants are declared by adding the constant keyword right after the colon delimiter, which guarantees they cannot be modified after compilation.

Ada
Pi : constant Float := 3.14;
Beginner
10. What is an if statement in Ada?

An if statement checks condition states and ends explicitly with an end if; statement.

Ada
if X > 0 then
   Put_Line("Positive");
end if;
Beginner
11. What is a loop in Ada?

Loops in Ada can be controlled using standard ranges or index iterations. Numeric attributes can be formatted as output text using the 'Image attribute.

Ada
for I in 1..10 loop
   Put_Line(Integer'Image(I));
end loop;
Beginner
12. What is an array in Ada?

Arrays explicitly define their boundary conditions during creation (e.g., indexes 1 to 5).

Ada
type My_Array is array (1..5) of Integer;
A : My_Array;
Beginner
13. What is a record in Ada?

A record allows programmers to group elements of varying types together into a cohesive custom type definition, similar to a struct in C.

Ada
type Person is record
   Name : String(1..20);
   Age  : Integer;
end record;
Beginner
14. What is exception handling in Ada?

Ada handles runtime exception boundaries using structured blocks, stopping failures from destabilising complex critical environments.

Ada
begin
   -- Potentially unsafe operation
   X := Y / Z;
exception
   when Constraint_Error =>
      Put_Line("Division by zero or overflow!");
end;
Beginner
15. What is the entry point of an Ada program?

The program's entry execution context starts within a standard procedure mapped directly as the main system loop configuration block.

Ada
procedure Main is
begin
   Put_Line("Main entry execution");
end Main;
Intermediate
16. What is a task in Ada?

A task is an active concurrent execution thread managed directly by Ada's compiler and runtime platform layer, enabling native, portable multi-threading support.

Ada
task type Worker is
   entry Start;
end Worker;

task body Worker is
begin
   accept Start;
   Put_Line("Task is running concurrently.");
end Worker;
Intermediate
17. What is rendezvous in Ada?

A rendezvous is Ada's fundamental synchronization mechanism, allowing safe data exchanges and thread coordination when multiple tasks meet.

Ada
accept Start do
   -- Synchronized mutual-exclusion zone
   Put_Line("Rendezvous active");
end Start;
Intermediate
18. What is generic in Ada?

Generic components are templates parameterized with types, subprograms, or values, facilitating compilation-level type-safe code reuse.

Ada
generic
   type Element is private;
procedure Swap(A, B : in out Element);
Intermediate
19. What is subtype?

A subtype defines a subset of an existing base type's values without instantiating a completely new distinct type category.

Ada
subtype Positive_Integer is Integer range 1 .. Integer'Last;
Intermediate
20. What is access type?

Access types are type-safe pointer alternatives in Ada used to securely allocate and dereference memory addresses dynamically.

Ada
type Int_Ptr is access Integer;
My_Ptr : Int_Ptr;
Intermediate
21. What is tagged type?

A tagged type enables object-oriented programming (OOP) paradigms in Ada, acting as a className base to support dynamic dispatching and inheritance.

Ada
type Instrument is tagged record
   ID   : Integer;
   Name : String(1..10);
end record;
Intermediate
22. What is a protected object?

A protected object provides coordinated lock synchronization, encapsulating data and locking thread entries automatically for concurrent access.

Ada
protected body Semaphore is
   entry Wait when Count > 0 is
   begin
      Count := Count - 1;
   end Wait;
   procedure Signal is
   begin
      Count := Count + 1;
   end Signal;
end Semaphore;
Intermediate
23. What is overloading?

Ada allows overloading, enabling multiple subprograms to declare identical names provided their signature parameters vary.

Ada
procedure Display(Item : Integer);
procedure Display(Item : Float);
Intermediate
24. What is recursion?

Recursion occurs when subprograms execute self-calls recursively to partition mathematical problems into manageable chunks.

Ada
procedure Recursive_Print (N : Positive) is
begin
   if N > 0 then
      Recursive_Print (N - 1);
      Put_Line (Integer'Image (N));
   end if;
end Recursive_Print;
Intermediate
25. What is pragma?

A pragma is a compiler directive used to configure optimisations, constraints, calling profiles, or target behaviours directly.

Ada
pragma Optimize(Time);
Intermediate
26. What is range constraint?

Range constraints restrict variable domains dynamically, catching overflow logic errors automatically via runtime type-checking engines.

Ada
procedure Test is
   type Small is range -10 .. 10;
   X : Small;
begin
   X := 5;
end Test;
Intermediate
27. What is dynamic allocation example?

Memory allocations are safely structured using pointer constructors inside active heap spaces.

Ada
type Int_Ptr is access Integer;
My_Ptr : Int_Ptr;
Intermediate
28. What is discriminated record?

Discriminated records function similarly to variant records, altering structural properties based on dynamic discriminant variables.

Ada
type Buffer(Size : Positive) is record
   Data : String(1 .. Size);
end record;
Intermediate
29. What is task entry?

Task entries establish structured communication interfaces to accept parameter payloads safely across thread boundaries.

Ada
task Server is
   entry Get_Status(Code : out Integer);
end Server;
Intermediate
30. What is delay statement?

Delay statements yield task executions temporarily, pausing threads for precise durations.

Ada
delay 2.5;  -- Pause task execution for 2.5 seconds
Advanced
31. What is real‑time support in Ada?

Ada provides native, deterministic scheduling models, priority‑inversion controls, and clock systems vital for high‑reliability embedded targets.

Ada
pragma Priority(Interrupt_Priority'Last);
Advanced
32. What is Ravenscar profile?

The Ravenscar Profile is a specialised tasking subset that guarantees deterministic, analysable, and safety‑certifiable real‑time concurrency.

Ada
pragma Profile(Ravenscar);
Advanced
33. What is contract‑based programming?

Contract‑based programming leverages Pre (preconditions) and Post (postconditions) aspects to mathematically verify subprogram correct states at boundaries.

Ada
procedure Deposit(Amount : Positive)
   with Pre  => Amount > 0,
        Post => Balance = Balance'Old + Amount;
Advanced
34. What is SPARK Ada?

SPARK is a specialised language subset and formal verification toolset. It mathematically proves the absence of runtime errors (like division by zero or buffer overflows) and verifies correctness.

Ada
procedure Safety_Critical_Process
   with SPARK_Mode => On;
Advanced
35. What is an enumeration type?

An enumeration type defines a set of named values, providing clear and type‑safe representation of symbolic constants.

Ada
type Color is (Red, Green, Blue);
Advanced
36. How to define a simple procedure?

A simple procedure that prints a string.

Ada
procedure Print (S : String) is
begin
   Put_Line(S);
end Print;
Advanced
37. How to define a function that adds two integers?

A function that returns the sum of two integers.

Ada
function Add (A, B : Integer) return Integer is
begin
   return A + B;
end Add;
Advanced
38. What is a package specification?

A package specification declares the public interface of a package, including types, subprograms, and constants.

Ada
package Stack is
   procedure Push (Item : Integer);
   function Pop return Integer;
end Stack;
Advanced
39. What is a package body?

A package body contains the implementation of the subprograms and data declared in the package specification.

Ada
package body Stack is
   ...
end Stack;
Advanced
40. What is a case statement?

A case statement selects one of several alternatives based on the value of an expression.

Ada
case X is
   when 1 => Put_Line("One");
   when 2 => Put_Line("Two");
   when others => Put_Line("Other");
end case;
Advanced
41. What is a while loop?

A while loop executes a sequence of statements repeatedly while a condition is true.

Ada
while X > 0 loop
   X := X - 1;
end loop;
Advanced
42. Example of an enumeration type.

Defining an enumeration type for fruits.

Ada
type My_Enum is (Apple, Banana, Orange);
Advanced
43. How to declare a 2D array?

A 2D array is declared using two dimensions in the array type definition.

Ada
type My_Array_2D is array (1..3, 1..3) of Integer;
Advanced
44. How to define a fixed-length string?

A fixed-length string is defined as an array of characters with a specific length.

Ada
type My_String is String (1..10);
Advanced
45. What is access all type?

access all allows a pointer to refer to any object of the designated type, including unconstrained arrays.

Ada
type My_Access is access all Integer;
Advanced
46. What is a tagged null record?

A tagged null record is the simplest form of a tagged type, serving as a root for inheritance hierarchies.

Ada
type My_Tagged is tagged null record;
Advanced
47. How to implement a semaphore using a protected object?

A semaphore can be built with a protected object having an entry and a procedure to manage counting.

Ada
protected type Semaphore is
   entry Wait;
   procedure Signal;
private
   Count : Natural := 0;
end Semaphore;
Advanced
48. How is a protected body defined?

The protected body contains the implementation of its entries, functions, and procedures.

Ada
protected body Semaphore is
   entry Wait when Count > 0 is
   begin
      Count := Count - 1;
   end Wait;
   procedure Signal is
   begin
      Count := Count + 1;
   end Signal;
end Semaphore;
Advanced
49. How to define a square function?

A function that returns the square of an integer.

Ada
function Square (X : Integer) return Integer is
begin
   return X * X;
end Square;
Advanced
50. Recursive procedure to print numbers.

A recursive procedure that prints numbers from 1 to N using recursion.

Ada
procedure Recursive_Print (N : Positive) is
begin
   if N > 0 then
      Recursive_Print (N - 1);
      Put_Line (Integer'Image (N));
   end if;
end Recursive_Print;
Advanced
51. What is pragma Inline?

pragma Inline suggests the compiler to expand the subprogram inline for performance.

Ada
pragma Inline (Square);
Advanced
52. What is pragma Preelaborate?

pragma Preelaborate ensures a package can be elaborated before any other code, useful for high‑integrity systems.

Ada
pragma Preelaborate (My_Package);
Advanced
53. What is pragma Restrictions?

pragma Restrictions disallows certain language features (e.g., tasking) to enforce a simpler, more predictable runtime.

Ada
pragma Restrictions (No_Tasking);
Advanced
54. Example of a range‑constrained type.

Defining a type that can only hold values between -10 and 10.

Ada
procedure Test is
   type Small is range -10 .. 10;
   X : Small;
begin
   X := 5;
end Test;
Advanced
55. What is a variant record?

A variant record (discriminated record) uses a discriminant to select between different record layouts.

Ada
type Rec (D : Boolean) is record
   case D is
      when True  => I : Integer;
      when False => F : Float;
   end case;
end record;
Advanced
56. How to declare multiple tasks?

Tasks can be declared as separate task objects or as an array of tasks.

Ada
task T1;
task T2;
-- ...
Advanced
57. What is a select statement?

A select statement allows a task to choose between multiple entry calls or conditional accepts.

Ada
select
   accept Entry1;
   ...
or
   accept Entry2;
   ...
end select;
Advanced
58. Example of a protected buffer (producer‑consumer).

A protected object that acts as a bounded buffer with Put and Get entries.

Ada
protected type Buffer is
   entry Put (Item : Integer);
   entry Get (Item : out Integer);
private
   Data : Integer;
   Empty : Boolean := True;
end Buffer;
Advanced
59. Function to compute power with loop.

A function that calculates Base raised to Exp using a simple loop.

Ada
function Power (Base : Integer; Exp : Natural) return Integer is
   Result : Integer := 1;
begin
   for I in 1..Exp loop
      Result := Result * Base;
   end loop;
   return Result;
end Power;
Advanced
60. What is a generic container package?

A generic package that provides container operations for any element type.

Ada
generic
   type Element is private;
package Generic_Container is
   procedure Insert (Item : Element);
   function Lookup (Key : Integer) return Element;
end Generic_Container;
Advanced
61. How to define an integer range type?

Defining a subtype or new type with a specific range.

Ada
type My_Integer is range 0 .. 100;
Advanced
62. How to specify floating point precision?

Using digits to define the number of decimal digits of precision.

Ada
type My_Real is digits 6;  -- 6 decimal digits
Advanced
63. What is a fixed‑point type?

Fixed‑point types are used for decimal arithmetic with a specified delta (smallest representable value).

Ada
type My_Fixed is delta 0.01 range -100.0 .. 100.0;
Advanced
64. A simple square root function.

Using exponentiation to compute square root.

Ada
function Sqrt (X : Float) return Float is
begin
   return X ** 0.5;
end Sqrt;
Advanced
65. How to implement a swap procedure?

Swapping two integer values using a temporary variable.

Ada
procedure Swap (A, B : in out Integer) is
   Temp : Integer;
begin
   Temp := A;
   A := B;
   B := Temp;
end Swap;
Advanced
66. How to specify representation for enumeration?

Using a representation clause to assign specific integer values to enumeration literals.

Ada
type My_Enum is (One, Two, Three);
for My_Enum use (One => 1, Two => 2, Three => 3);
Advanced
67. What is a record representation clause?

A representation clause specifies the exact bit layout of a record, useful for low‑level interfacing.

Ada
type My_Record is record
   A : Integer;
   B : Float;
end record;

for My_Record use record
   A at 0 range 0 .. 31;
   B at 4 range 0 .. 31;
end record;
Advanced
68. Define an enumeration for days.

Enumerating the days of the week.

Ada
type Day is (Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday);
Advanced
69. Function to check if a day is weekend.

Using the Day enumeration to determine weekend.

Ada
function Is_Weekend (D : Day) return Boolean is
begin
   return D = Saturday or D = Sunday;
end Is_Weekend;
Advanced
70. What is pragma Assert?

pragma Assert is used to insert runtime assertions for debugging and verification.

Ada
pragma Assert (X > 0, "X must be positive");
Advanced
71. What is pragma Debug?

pragma Debug includes debugging code only when debugging is enabled, avoiding overhead in production.

Ada
pragma Debug (Put_Line ("Entering procedure"));
Advanced
72. What is a modular type?

A modular type defines an unsigned integer with wrap‑around arithmetic modulo a power of two.

Ada
type My_Mod is mod 256;
Advanced
73. How to implement a periodic task?

A periodic task that executes at regular intervals using a delay loop.

Ada
task body Periodic_Task is
   Running : Boolean := True;
begin
   accept Start;
   while Running loop
      delay 1.0;
      Put_Line ("Tick");
      select
         accept Stop;
         Running := False;
      or
         delay 0.0;
      end select;
   end loop;
end Periodic_Task;
Advanced
74. Function to check primality.

Checking if a number is prime using trial division up to sqrt.

Ada
function Is_Prime (N : Positive) return Boolean is
   Result : Boolean := True;
begin
   if N < 2 then
      return False;
   end if;
   for I in 2 .. Natural (Sqrt (Float (N))) loop
      if N mod I = 0 then
         return False;
      end if;
   end loop;
   return True;
end Is_Prime;
Advanced
75. Implementation of bubble sort.

Bubble sort algorithm for an integer array.

Ada
procedure Sort (Arr : in out Integer_Array) is
   Temp : Integer;
begin
   for I in Arr'First .. Arr'Last - 1 loop
      for J in Arr'First .. Arr'Last - I - 1 loop
         if Arr (J) > Arr (J + 1) then
            Temp := Arr (J);
            Arr (J) := Arr (J + 1);
            Arr (J + 1) := Temp;
         end if;
      end loop;
   end loop;
end Sort;
Advanced
76. Binary search algorithm.

Binary search on a sorted integer array.

Ada
function Binary_Search (Arr : Integer_Array; Target : Integer) return Integer is
   Low  : Integer := Arr'First;
   High : Integer := Arr'Last;
   Mid  : Integer;
begin
   while Low <= High loop
      Mid := (Low + High) / 2;
      if Target = Arr (Mid) then
         return Mid;
      elsif Target < Arr (Mid) then
         High := Mid - 1;
      else
         Low := Mid + 1;
      end if;
   end loop;
   return -1;  -- Not found
end Binary_Search;
Advanced
77. Recursive Fibonacci function.

Computing Fibonacci numbers using recursion.

Ada
function Fibonacci (N : Natural) return Natural is
begin
   if N <= 1 then
      return N;
   else
      return Fibonacci (N - 1) + Fibonacci (N - 2);
   end if;
end Fibonacci;
Advanced
78. Quick sort implementation.

Quick sort using recursion and partitioning.

Ada
procedure Quick_Sort (Arr : in out Integer_Array; Low, High : Integer) is
   Pivot : Integer;
   I, J  : Integer;
begin
   if Low < High then
      Pivot := Arr (High);
      I := Low;
      for J in Low .. High - 1 loop
         if Arr (J) < Pivot then
            Swap (Arr (I), Arr (J));
            I := I + 1;
         end if;
      end loop;
      Swap (Arr (I), Arr (High));
      Quick_Sort (Arr, Low, I - 1);
      Quick_Sort (Arr, I + 1, High);
   end if;
end Quick_Sort;
Advanced
79. Node definition for a linked list.

A record with a value and an access to the next node.

Ada
type Node is record
   Value : Integer;
   Next  : access Node;
end record;
Advanced
80. Inheritance example with tagged types.

Base type Root and derived Child with overriding method.

Ada
type Root is tagged null record;
procedure Method (Obj : Root);

type Child is new Root with record
   Extra : Integer;
end record;
overriding procedure Method (Obj : Child);
Advanced
81. Access type to a string.

Defining an access type that can point to a String.

Ada
type String_Access is access String;
Advanced
82. Function to check string equality.

Comparing two strings character by character.

Ada
function Is_Equal (A, B : String) return Boolean is
begin
   if A'Length /= B'Length then
      return False;
   end if;
   for I in A'Range loop
      if A(I) /= B(I) then
         return False;
      end if;
   end loop;
   return True;
end Is_Equal;
Advanced
84. Recursive factorial function.

Computing factorial using recursion.

Ada
function Factorial (N : Natural) return Natural is
begin
   if N = 0 then
      return 1;
   else
      return N * Factorial (N - 1);
   end if;
end Factorial;
Advanced
85. Procedure to compute GCD.

Euclidean algorithm for greatest common divisor.

Ada
procedure GCD (A, B : Positive; Result : out Positive) is
   X, Y : Positive := A, B;
begin
   while X /= Y loop
      if X > Y then X := X - Y; else Y := Y - X; end if;
   end loop;
   Result := X;
end GCD;
Advanced
86. Recursive power function.

Computing power using recursion.

Ada
function Pow (Base : Integer; Exp : Natural) return Integer is
begin
   if Exp = 0 then
      return 1;
   else
      return Base * Pow (Base, Exp - 1);
   end if;
end Pow;
Advanced
87. What is pragma Suppress?

pragma Suppress disables certain runtime checks (e.g., index checking) for performance.

Ada
pragma Suppress (Index_Check);
Advanced
88. What is pragma Detect_Blocking?

pragma Detect_Blocking raises an exception when a task blocks inside a protected action, aiding in deadlock detection.

Ada
pragma Detect_Blocking;
Advanced
89. How to define a private type?

A private type hides its internal structure, exposing only operations through the package.

Ada
package My_Package is
   type My_Type is private;
   procedure Set (Item : My_Type; Value : Integer);
   function Get (Item : My_Type) return Integer;
private
   type My_Type is record
      Value : Integer;
   end record;
end My_Package;
Advanced
90. Implementation of the private type package body.

The package body contains the actual implementation of the operations.

Ada
package body My_Package is
   procedure Set (Item : My_Type; Value : Integer) is
   begin
      Item.Value := Value;
   end Set;
   function Get (Item : My_Type) return Integer is
   begin
      return Item.Value;
   end Get;
end My_Package;
Advanced
91. Periodic task using Ada.Real_Time.

A periodic loop using delay until for precise timing.

Ada
with Ada.Real_Time; use Ada.Real_Time;

procedure Periodic is
   Period : constant Time_Span := Milliseconds (100);
   Next   : Time := Clock + Period;
begin
   loop
      delay until Next;
      Put_Line ("Tick");
      Next := Next + Period;
   end loop;
end Periodic;
Advanced
92. Define a byte type with modular type.

A modular type with 8‑bit size.

Ada
type Byte is mod 256;
for Byte'Size use 8;
Advanced
93. How to specify size for an enumeration?

Setting the size of enumeration types using a representation clause.

Ada
type My_Enum is (A, B, C);
for My_Enum'Size use 8;
Advanced
94. What is pragma Pack?

pragma Pack instructs the compiler to reduce the storage size of a record by eliminating padding.

Ada
pragma Pack (My_Record);
Advanced
95. What is pragma Unsuppress?

pragma Unsuppress re‑enables checks that were previously suppressed.

Ada
pragma Unsuppress (All_Checks);
Advanced
96. How to set alignment for a record?

Using an alignment clause to specify the byte alignment of a record type.

Ada
type My_Record is record
   A : Integer;
   B : Float;
end record;

for My_Record'Alignment use 4;
Advanced
97. Procedure with IN parameter.

Example showing a procedure that takes an IN parameter and uses a local variable.

Ada
procedure My_Procedure (Param : in Integer) is
   Local : Integer := Param;
begin
   Local := Local + 1;
end My_Procedure;
Advanced
98. Max function for two integers.

Function that returns the maximum of two integers.

Ada
function Max (A, B : Integer) return Integer is
begin
   if A > B then return A; else return B; end if;
end Max;
Advanced
99. Swap procedure for integers.

Swapping two integers using a temporary variable.

Ada
procedure Swap (A, B : in out Integer) is
   T : Integer := A;
begin
   A := B;
   B := T;
end Swap;
Advanced
100. How to define an unconstrained array?

An array type with an indefinite range, allowing different sizes upon instantiation.

Ada
type My_Array is array (Positive range <>) of Integer;