LearnPracticeExamsMocks

Clear practice, useful explanations and steady progress for exam preparation.

Study

AptitudeLogical reasoningVerbal abilityTechnical aptitudeAI & modern dev

Explore

Practice libraryLocal progressExam patternsFor collegesSearchAbout AISEAFAQ

Trust & support

ContactReport a problemContent correctionsAccessibility
© 2026 AISEA. Built for focused learning.Privacy · Terms · Editorial policy
Home
›Technical Aptitude
›Programming Concepts
Technical
Programming ConceptsPractice
Data Structures
Algorithms
DBMS
Operating Systems
Computer Networks
C Programming
Java
Python

Pseudocode and programming MCQs with answers

Trace variables, loops, branches and functions, and revise programming fundamentals with worked examples and explained questions. Use these concepts for placement pseudocode preparation, then write and test code in your own environment.

501 practice questionsPage updated 24 Sept 2026Reviewed by AISEA Editorial DeskPractice questions
Practise this concept

Programming concepts are the reusable ideas behind most languages: data, variables, control flow, functions, scope, recursion and object-oriented design. Technical aptitude questions usually test whether you can trace these ideas accurately, choose the right abstraction and predict behavior at the boundaries. Syntax varies by language, but the underlying reasoning patterns remain useful across languages.

Key formulas and rules

5 rules
1

Structured Program Flow: Program Control=Sequence+Selection+Iteration

2

Safe Recursion Structure: Recursive Function=Base Case+Progress toward Base Case+Recursive Step

3

Contiguous Array Address: Address(A[i])=Base Address+i×sizeof(Element)

4

2D Array Row-Major Address: Address(A[i][j])=Base Address+(i×C+j)×sizeof(Element)

5

Function Execution Model: Function Execution=Call Stack Frame+Passed Arguments+Local Scope→Return Value

Key concepts

Data types and variables

A data type describes the kind of value a program can store and the operations that are meaningful for it. Common primitive types include integers, floating-point numbers, characters and booleans. Arrays, strings, objects and records are composite or reference-like structures in many languages. A variable binds a name to a value or object, and assignment rules depend on the language.

Sequence, selection and iteration

Sequence runs statements in order. Selection chooses a path using if-else or a similar construct. Iteration repeats a block with a for, while or equivalent loop. When tracing code, record the condition, the changing variable and the number of times the loop body executes. A loop must make progress toward its stopping condition.

Functions, parameters and return values

A function packages a task behind a name. Parameters receive inputs, local variables hold temporary state, and a return statement sends a result to the caller. Separate parameters from arguments: parameters appear in the definition, while arguments are the values supplied at a call. Small functions with clear inputs and outputs are easier to test and reuse.

Scope, lifetime and mutability

Scope is the region where a name can be accessed. Lifetime is how long the associated value or object exists. A local name may hide a name with the same spelling in an outer scope. Mutable objects can change without replacing the object, while immutable values require a new value for a change. These distinctions explain many aliasing and state bugs.

Recursion

A recursive function calls itself on a smaller or simpler subproblem. Every correct recursive design needs a base case and a step that moves toward it. Calls use stack frames, so deep recursion can consume significant memory or exceed a runtime limit. Iteration and recursion can express the same logic, but their clarity and resource use may differ.

Object-oriented programming

An object combines state and behavior. A class is a blueprint from which objects can be created. Encapsulation keeps data and the operations that protect it together. Abstraction exposes essential behavior while hiding implementation detail. Inheritance derives a type from another type, and polymorphism lets the same interface select different implementations. Use inheritance only when the relationship is genuinely an is-a relationship.

References, copying and complexity

Two variables may contain independent copies or refer to the same object, depending on the operation and language. Mutating a shared object can affect every alias. For performance, estimate how work grows with input size: direct indexing is commonly constant time, one full pass is linear, and two nested full passes are commonly quadratic. Confirm the actual data structure and operation before assigning a complexity.

Check the idea while it is fresh.Open a focused exercise without losing this article.Practise this concept

Worked examples

Example 1

Consider this value-based function:

function addOne(value) {
  value = value + 1;
  return value;
}

let score = 4;
let updated = addOne(score);

What are the values of score and updated after the call?

Solution

Step 1: The argument score has the value 4 when the function is called.
Step 2: The parameter value receives that value for the call.
Step 3: Changing value to 5 changes the function's local binding, not score.
Step 4: The function returns 5, which is assigned to updated.
Answer: score remains 4 and updated becomes 5. The exact copy/reference behavior for objects is language-dependent, so always check the type being passed.

Example 2

What is the output of this recursive function for factorial(4)?

function factorial(n) {
  if (n === 0) return 1;
  return n * factorial(n - 1);
}

Solution

Step 1: The base case is factorial(0) = 1.
Step 2: factorial(4) calls 4 × factorial(3).
Step 3: The calls continue as 4 × 3 × 2 × 1 × factorial(0).
Step 4: The base case returns 1, so the result is 4 × 3 × 2 × 1 × 1=24.
Answer: 24. The call argument decreases by one each time, so the recursion reaches its base case.

Example 3

What is printed, and what is the time complexity?

for i from 1 to n:
    print(i)

Solution

Step 1: The loop starts at 1 and visits each integer through n.
Step 2: It prints 1, 2, 3 and so on up to n.
Step 3: The body executes n times, with constant work per iteration.
Answer: It prints the integers from 1 to n, and its time complexity is O(n).

Example 4

A class keeps a private balance field and exposes deposit(amount) and getBalance() methods. Which OOP principle is most directly illustrated?
A) Encapsulation
B) Inheritance
C) Recursion
D) Iteration

Solution

Step 1: The balance field is kept behind the class boundary.
Step 2: Other code uses controlled methods instead of changing the field directly.
Step 3: Bundling state with the operations that manage it is encapsulation.
Answer: A) Encapsulation.

Example 5

What does this function return, and what happens to the outer total?

let total = 10;
function addLocal() {
  let total = 3;
  return total + 1;
}

The function is called once.

Solution

Step 1: The total declared inside addLocal has local scope.
Step 2: It shadows the outer total only while the function runs.
Step 3: The function returns the local value 3 plus 1, which is 4.
Step 4: The outer total is never assigned a new value.
Answer: The function returns 4 and the outer total remains 10.

Example 6

An application accepts a list of Shape values. Circle and Rectangle each provide their own draw() implementation, and the renderer calls shape.draw() without checking the concrete type. Which concept makes this design flexible?
A) Polymorphism
B) Global scope
C) Primitive typing
D) Tail recursion

Solution

Step 1: The renderer depends on the common Shape behavior.
Step 2: Each concrete object supplies its own implementation of draw().
Step 3: One interface is used with multiple implementations.
Answer: A) Polymorphism.

Representative solved questions

See the kind of question in this topic before opening the full practice set.

Question 1

What is the space complexity of recursive Fibonacci without memoization?

  1. A.

    O(n) due to call stack

  2. B.

    O(logn) due to binary recursion

  3. C.

    O(1) as it uses no extra space

  4. D.

    O(n2) due to repeated calculations

Answer: A. O(n) due to call stack

Explanation

Step 1: Each recursive call adds a stack frame
Step 2: Maximum depth is n (the parameter value)
Step 3: Space is used for call stack, not heap
Step 4: Two branches share the same stack depth
Answer: O(n) due to call stack

Sources and review notes

This is an AISEA-authored practice question.

Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening

Question 2

Which sorting algorithm has O(n logn) average case but O(n2) worst case?

  1. A.

    MergeSort

  2. B.

    QuickSort

  3. C.

    HeapSort

  4. D.

    Counting Sort

Answer: B. QuickSort

Explanation

Step 1: QuickSort divides with pivot
Step 2: Average case: balanced partitions give O(n logn)
Step 3: Worst case: unbalanced partitions give O(n2)
Step 4: MergeSort and HeapSort guarantee O(n logn)
Answer: QuickSort

Sources and review notes

This is an AISEA-authored practice question.

Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening

Question 3

What is the difference between compile-time and runtime polymorphism?

  1. A.

    Compile-time: method overloading; Runtime: method overriding

  2. B.

    Compile-time: method overriding; Runtime: method overloading

  3. C.

    Compile-time uses more memory

  4. D.

    They are the same thing

Answer: A. Compile-time: method overloading; Runtime: method overriding

Explanation

Step 1: Overloading resolved at compile-time
Step 2: Overriding resolved at runtime via virtual table
Step 3: Early binding vs late binding
Step 4: Both enable different implementations
Answer: Compile-time: method overloading; Runtime: method overriding

Sources and review notes

This is an AISEA-authored practice question.

Review status: accepted · Reviewed 2026-08-13 · structure and answer-key checks, editorial quality checks, duplicate screening

Common mistakes and useful habits

  • Trace variables in a small table when a question contains several assignments or nested calls.
  • For every loop, identify the initial value, stopping condition, update step and number of iterations.
  • For recursion, write the base case first and verify that every recursive call moves closer to it.
  • Distinguish scope from lifetime: a name can be inaccessible even while its associated object remains alive elsewhere.
  • When comparing pass-by-value and references, ask whether the operation reassigns a binding or mutates a shared object.
  • Use encapsulation to protect invariants, not just to hide code. Public methods should preserve valid object state.
  • Estimate complexity from the operation and data structure actually used, not from the topic label alone.

Sources and review notes

Reviewed by AISEA Editorial Desk on 1 Sep 2026.

  • The page presents language-neutral fundamentals and labels behavior that varies by language or data type.
  • Worked examples were traced for scope, recursion termination, value semantics, OOP principles and basic complexity.
  • Object-oriented definitions were checked against the cited platform documentation without turning Java-specific syntax into a universal rule.
  1. JavaScript GuideMDN Web Docs · Checked 1 Sep 2026Supports: variables, control flow, loops, functions, scope, objects and classes as concrete programming examples
  2. Object-Oriented Programming ConceptsOracle Java Tutorials · Checked 1 Sep 2026Supports: objects, classes, encapsulation, inheritance, interfaces and polymorphism
  3. More Control Flow ToolsPython Documentation · Checked 1 Sep 2026Supports: function definitions, parameters, recursion examples and control-flow fundamentals

Ready to test your understanding?

Work through 501 questions with explanations after each answer.

Start practice
Next topic: Data Structures →

Keep building the same skill family.

Data Structures

Arrays, stacks, queues, trees, graphs

Open practice
Algorithms

Sorting, searching, complexity analysis

Open practice
DBMS

Relational databases, SQL, normalization

Open practice
On this page
Formulas and rulesKey conceptsWorked examplesRepresentative questionsCommon mistakesSources and reviewRelated practice

Suggest a correction