Programming, Databases & AI MCQs With Answers
Programming and databases are the heart of computer science, and AI is now joining them in exam papers. These programming, database and AI MCQs cover algorithms, variables, loops, functions and recursion, high-level and low-level languages such as Python, C++, FORTRAN and assembly, HTML, CSS and JavaScript, compilers, assemblers and linkers, object-oriented programming and polymorphism, stacks, binary search, sorting and time complexity, SQL, primary keys, joins, normal forms and ACID properties, MySQL and MongoDB, SDLC models such as Agile and Spiral, version control with Git, and AI, neural networks, transformers and large language models. They help lecturer, IT and NTS candidates.
Take a scored quiz instead →In Relational Database Management Systems (RDBMS), what property ensures that all operations within a database transaction either complete successfully or roll back completely?
Atomicity (the 'A' in ACID) guarantees an 'all-or-nothing' execution model. If any operation within a transaction fails, the entire transaction is aborted and rolled back to preserve database integrity.
Which SQL command is used to remove a table structure and all of its records permanently from a database schema?
DROP TABLE deletes both the table structure and its data permanently (DDL command). TRUNCATE removes all rows while keeping the structure intact, and DELETE removes selected rows (DML command).
Which Normal Form eliminates partial dependency by ensuring that all non-key attributes are fully functionally dependent on the entire primary key?
2NF requires the table to be in 1NF and have no partial dependencies (non-prime attributes depending on only part of a composite primary key). 3NF eliminates transitive dependencies.
Which type of database JOIN returns all records from the left table and matching records from the right table, filling with NULL where no match exists?
A LEFT JOIN (or LEFT OUTER JOIN) fetches every record from the left table. If a row has no corresponding match in the right table, SQL returns NULL for all right-table columns.
Which linear data structure operates strictly on a Last-In, First-Out (LIFO) access mechanism?
A Stack works on LIFO (Last-In, First-Out), where push and pop operations happen at the top element. A Queue operates on FIFO (First-In, First-Out).
What is the worst-case time complexity of the standard QuickSort algorithm when selecting a poor pivot element on an already sorted array?
QuickSort uses Divide and Conquer. While its average time complexity is O(n log n), choosing an extreme element (smallest or largest) as pivot on a sorted array results in worst-case time complexity of O(n²).
In Object-Oriented Programming (OOP), what term describes the ability of a single interface or method name to take multiple forms based on the object context?
Polymorphism ('many forms') allows methods to behave differently based on the calling object (e.g., via Method Overloading or Method Overriding). Encapsulation hides internal data, while Abstraction hides implementation complexity.
Which search algorithm requires data to be sorted beforehand and repeatedly divides the search interval in half?
Binary Search requires a pre-sorted array. It compares the target value to the middle element, cutting the search domain in half with each iteration, achieving an efficient time complexity of O(log n).
Which programming language paradigm uses mathematical functions and avoids changing state or mutable data?
Functional Programming (e.g., Haskell, Lisp) treats computation as the evaluation of pure mathematical functions, avoiding side effects and mutable state, unlike Imperative or Object-Oriented styles.
Which software development methodology emphasizes iterative delivery, customer collaboration, cross-functional self-organizing teams, and flexibility to changing requirements?
Agile Software Development delivers functional software in short sprints (1–4 weeks), adapting swiftly to changing user needs. Waterfall is linear and sequential, making mid-course adjustments difficult.
Which SDLC model incorporates explicit risk assessment and management at every iterative phase of development?
The Spiral Model (proposed by Barry Boehm) combines iterative development with systematic risk analysis across four quadrants: Planning, Risk Analysis, Engineering, and Evaluation.
Which markup language is the standard language for creating web pages and defining their structure?
HTML (HyperText Markup Language) structures web content. CSS controls layout and styling, JavaScript enables dynamic client-side scripting, and PHP executes server-side logic.
Which field of Artificial Intelligence enables machines to process, interpret, and understand human text and spoken language?
Natural Language Processing (NLP) combines computational linguistics with machine learning to enable computers to understand, parse, and generate human language.
What is the primary function of an Assembler in computer programming?
An Assembler translates symbolic Assembly Language (mnemonics like MOV, ADD) into raw machine code (0s and 1s). Compilers translate entire high-level programs at once, while Interpreters translate line by line.
Which type of software maintenance is performed to modify a software system to adapt to changes in its surrounding environment (e.g., new OS version)?
Adaptive Maintenance alters software to stay compatible with changing external environments (OS, hardware, regulations). Corrective fixes bugs, Perfective adds new features, and Preventive refactors code to avoid future failures.
What term refers to the process of converting human-readable source code into an intermediate bytecode format executed by a virtual machine (e.g., Java JVM)?
Java compiles source code (.java) into platform-independent Bytecode (.class), which is then interpreted or JIT-compiled by the Java Virtual Machine (JVM) on target platforms.
Which system software component translates a high-level source code file into object code modules prior to linking?
A Compiler translates entire high-level source code into machine code/object code. The Linker then combines object modules with external libraries to generate an executable binary file (.exe).
Which traversal algorithm visits a Binary Search Tree (BST) nodes in strict ascending sorted key order?
In-order Traversal (Left subtree -> Root node -> Right subtree) visits nodes of a Binary Search Tree in sorted ascending order. Pre-order is used for cloning, and Post-order for node deletion.
In artificial neural networks, which function is applied to the weighted sum of inputs at a neuron to introduce non-linearity into the network model?
Activation Functions (such as ReLU, Sigmoid, or Tanh) introduce non-linear mapping into neural networks, enabling them to learn complex non-linear patterns in data.
Which programming language, created by Guido van Rossum in 1991, is widely used in Data Science and AI?
Python is a high-level, interpreted programming language created by Dutch developer Guido van Rossum and released in 1991. Renowned for its simple syntax and extensive libraries (NumPy, Pandas, PyTorch), it is the leading language for Data Science, Machine Learning, and Artificial Intelligence.
What does SQL stand for in database management systems?
SQL stands for Structured Query Language. Developed by IBM in the 1970s, SQL is the standardized programming language used to create, query, update, manage, and manipulate data stored in Relational Database Management Systems (RDBMS) like MySQL, PostgreSQL, and Oracle.
In relational databases, what is a column that uniquely identifies each row/record in a table called?
A Primary Key is a database column (or set of columns) that uniquely identifies each individual record/row in a relational database table. Primary key values must be completely unique and cannot contain NULL values.
What generative AI architecture introduced by Google researchers in 2017 forms the foundation of modern LLMs like ChatGPT and Gemini?
The Transformer architecture was introduced in the seminal 2017 paper 'Attention Is All You Need' by Google researchers. Utilizing self-attention mechanisms, Transformers process sequential data in parallel, serving as the core foundation for modern Large Language Models (LLMs) like GPT-4, Claude, and Gemini.
What does LLM stand for in modern Artificial Intelligence applications?
LLM stands for Large Language Model. It refers to advanced deep-learning artificial intelligence models trained on massive text datasets (containing hundreds of billions of parameters) to understand, generate, translate, and synthesize human language.
What is the process of finding and fixing errors in a computer program called?
- Debugging means finding and fixing errors in code.
- It is an important part of software development.
- Programmers use special tools to help find errors.
What is a set of step-by-step instructions used to solve a problem called?
- An algorithm is a set of steps to solve a problem.
- It forms the logic behind computer programs.
- A good algorithm gives a correct result in a set number of steps.
What is a named storage location in a program that can hold changing data called?
- A variable stores data that can change while a program runs.
- It has a name and usually a specific data type.
- Examples include storing a number or a piece of text.
What is a reusable block of code that performs a specific task called?
- A function is a reusable block of code for a specific task.
- It can be called multiple times in a program.
- Functions make programs more organized and easier to read.
What is a programming structure that repeats a block of code multiple times called?
- A loop repeats a block of code multiple times.
- Common types include for loops and while loops.
- Loops help avoid writing the same code repeatedly.
Which programming language is widely known for its simple, easy-to-read syntax for beginners?
- Python is known for its simple, readable syntax.
- It is commonly used for beginners learning to code.
- Python is also widely used in data analysis and AI.
Which language is used to control the colors, fonts, and layout of a webpage?
- CSS controls the visual style of a webpage.
- It handles colors, fonts, and layout.
- CSS works together with HTML.
Which language is commonly used to add interactive features to a webpage?
- JavaScript adds interactivity to webpages.
- It runs directly inside most web browsers.
- HTML, CSS, and JavaScript are the three core web technologies.
Which term describes a single row of data within a database table?
- A record is a single row of data in a database table.
- It represents one complete entry, like one customer.
- A record is made up of several fields.
What is the technology that lets machines perform tasks that normally need human intelligence called?
- Artificial Intelligence lets machines perform human-like tasks.
- It is used in voice assistants and recommendations.
- AI includes areas like machine learning.
What is a computer program designed to simulate a conversation with a user called?
- A chatbot simulates a conversation with a user.
- It is often used for customer service.
- Some chatbots use artificial intelligence to respond.
Which language is ‘Low-level’?
• Low-level languages are closer to machine code and hardware architecture.
• Assembly language uses mnemonics corresponding to machine instructions.
• High-level languages are more readable and abstracted from hardware.
Which of these is a ‘Database’ management system?
• MySQL is a popular open-source relational database management system (RDBMS).
• It uses Structured Query Language (SQL) for database operations.
• Other examples include PostgreSQL and Oracle Database.
Which is a ‘High-level’ programming language?
• High-level languages are designed for ease of use by humans.
• They use abstract concepts and require a compiler or interpreter.
• Python is highly popular for its readability and large ecosystem.
What is a ‘Bug’ in a computer program?
• Bugs are defects that cause software to produce incorrect results or crash.
• The process of finding and fixing them is called 'debugging'.
• Complex systems are prone to bugs.
What is the function of a ‘Compiler’s linker’?
• After compilation, source code is converted into object code.
• The linker joins these object files and library files into a final runnable program.
• It resolves external references.
Which of these is a ‘Relational database’ model?
• Relational databases store data in tables (rows and columns).
• They use foreign keys to relate data across tables.
• SQL is the standard language for relational databases.
Which is a ‘High-level’ language for scientific computing?
• FORTRAN (Formula Translation) was developed for scientific and engineering calculations.
• It is one of the oldest high-level languages.
• It remains used in specialized fields.
What is a ‘Database’?
• Databases allow for efficient storage, retrieval, and updates of large data sets.
• They are managed by Database Management Systems (DBMS).
• Essential for modern software and business operations.
What is ‘C++’?
• C++ was created as an extension of the C language, adding classes (Object-Oriented Programming).
• It is known for its high performance and control over hardware.
• Commonly used for games, operating systems, and heavy applications.
Which of these is used for ‘Version control’?
• Git tracks changes in code over time, allowing for collaboration.
• It allows developers to revert to previous versions if needed.
• Essential for team-based software engineering.
Which file extension is used for ‘Python’ scripts?
• .py is the standard extension for Python source files.
• It is an interpreted language.
• Python is popular for data science, AI, and automation.
Which of these is a ‘Non-relational’ (NoSQL) database?
• NoSQL databases are designed for unstructured or semi-structured data.
• They offer flexibility and scalability compared to traditional relational models.
• Popular in big data applications.
What is ‘Syntax’ in programming?
• Syntax errors occur when code violates the language's grammar rules.
• The compiler/interpreter will reject syntactically incorrect code.
• It is the 'language' of the programming language.
What is ‘Object-Oriented Programming’ (OOP)?
• OOP focuses on bundling data and behavior into objects.
• Key concepts: encapsulation, inheritance, polymorphism.
• Major languages: Java, C++, Python, C#.
Which of these is a ‘Database’ query language?
• SQL (Structured Query Language) is the standard for accessing databases.
• Used for creating, reading, updating, and deleting data.
• Compatible with almost all relational database systems.
What is ‘Recursion’ in programming?
• Recursive functions solve problems by breaking them into smaller sub-problems.
• Must have a 'base case' to prevent infinite loops.
• Useful for tree and graph algorithms.
What does ‘HTML’ stand for?
• HTML is used to structure content on the web.
• Uses tags like
and
.
• Interpreted by web browsers.
