Computer Programming Examination (Python, Java, C++)

Total Questions: 100

Format: Short Answer / Multiple Choice Style

Level: Beginner to Intermediate


SECTION A: General Programming Concepts (1–25)


Q: What is programming?

A: The process of writing instructions for a computer to execute.


Q: What is a programming language?

A: A formal language used to communicate with a computer.


Q: What is a variable?

A: A storage location identified by a name that holds data.


Q: What is an algorithm?

A: A step-by-step method for solving a problem.


Q: What is a compiler?

A: A program that converts source code into machine code.


Q: What is an interpreter?

A: A program that executes code line by line.


Q: What is debugging?

A: The process of finding and fixing errors in code.


Q: What is syntax?

A: The set of rules defining the structure of code in a language.


Q: What is pseudocode?

A: A plain-language outline of a program’s logic.


Q: What is a data type?

A: Defines the type of data a variable can store (e.g., int, float, string).


Q: What is a constant?

A: A value that cannot be changed during program execution.


Q: What is a function?

A: A block of code designed to perform a specific task.


Q: What is recursion?

A: A function calling itself.


Q: What is an array?

A: A collection of elements stored in contiguous memory locations.


Q: What is object-oriented programming (OOP)?

A: A paradigm based on objects containing data and methods.


Q: What is encapsulation?

A: Restricting access to internal object data.


Q: What is inheritance?

A: The ability of one class to derive properties from another.


Q: What is polymorphism?

A: The ability to use a single interface for different data types.


Q: What is abstraction?

A: Hiding complex details and showing only necessary information.


Q: What is a loop?

A: A structure that repeats a block of code multiple times.


Q: What is an IDE?

A: Integrated Development Environment — software for coding and debugging.


Q: What is source code?

A: The original human-readable code written by a programmer.


Q: What is machine code?

A: Binary instructions executed directly by the computer.


Q: What is an API?

A: Application Programming Interface — defines interactions between software components.


Q: What is version control?

A: Managing changes to source code (e.g., using Git).


SECTION B: Python Programming (26–50)


Q: Who developed Python?

A: Guido van Rossum.


Q: When was Python created?

A: 1991.


Q: What is the file extension of Python files?

A: .py


Q: What is indentation used for in Python?

A: To define code blocks (e.g., loops, functions).


Q: What is the keyword to define a function in Python?

A: def


Q: How do you print output in Python?

A: print("Hello World")


Q: What symbol is used for comments in Python?

A: #


Q: What is a list in Python?

A: A collection of ordered, changeable items.


Q: How do you create a list in Python?

A: my_list = [1, 2, 3]


Q: What is a tuple?

A: An ordered, immutable collection of items.


Q: What is a dictionary?

A: A collection of key-value pairs.


Q: How do you start a loop in Python?

A: for or while


Q: What is the keyword to import a module?

A: import


Q: How do you define a class in Python?

A: class MyClass:


Q: What is self in Python classes?

A: Refers to the instance of the class.


Q: What is the use of return?

A: To send a result from a function.


Q: How do you handle exceptions in Python?

A: Using try and except blocks.


Q: What is a lambda function?

A: An anonymous, one-line function defined with lambda.


Q: What is slicing in Python?

A: Extracting parts of sequences using [start:end].


Q: What is the use of len()?

A: Returns the length of an object.


Q: What is the Python Package Index (PyPI)?

A: A repository for third-party Python packages.


Q: What is the difference between == and is?

A: == checks value equality; is checks object identity.


Q: What library is used for data analysis in Python?

A: Pandas.


Q: What is the keyword to exit a loop early?

A: break


Q: How do you read input from a user?

A: input("Enter value: ")



 SECTION C: Java Programming (51–75)


Q: Who developed Java?

A: James Gosling.


Q: When was Java released?

A: 1995.


Q: What is the extension of Java files?

A: .java


Q: What is the JVM?

A: Java Virtual Machine — executes Java bytecode.


Q: What is JDK?

A: Java Development Kit — includes tools to develop Java programs.


Q: What is JRE?

A: Java Runtime Environment — runs Java applications.


Q: What is a class in Java?

A: A blueprint for creating objects.


Q: What keyword is used to create an object?

A: new


Q: What is the main method signature in Java?

A: public static void main(String[] args)


Q: What does System.out.println() do?

A: Prints text to the console.


Q: What are Java data types divided into?

A: Primitive and Non-primitive.


Q: Give two examples of primitive types.

A: int, double.


Q: What is the default value of an uninitialized int variable?

A: 0.


Q: What keyword prevents inheritance?

A: final


Q: What is a constructor?

A: A special method used to initialize objects.


Q: Can constructors be overloaded?

A: Yes.


Q: What is method overloading?

A: Having multiple methods with the same name but different parameters.


Q: What is inheritance in Java?

A: When one class derives attributes from another using extends.


Q: What is an interface?

A: A reference type defining abstract methods.


Q: What is the keyword for inheritance?

A: extends


Q: What is exception handling in Java?

A: Managing runtime errors using try-catch.


Q: What keyword is used to inherit a class?

A: extends


Q: What is the parent class of all Java classes?

A: Object


Q: What is the keyword for packages?

A: package


Q: What is garbage collection?

A: Automatic memory management in Java.


⚙ SECTION D: C++ Programming (76–100)


Q: Who developed C++?

A: Bjarne Stroustrup.


Q: What is the file extension of C++ files?

A: .cpp


Q: What does OOP stand for?

A: Object-Oriented Programming.


Q: What is the entry point of a C++ program?

A: int main()


Q: What is #include <iostream> used for?

A: To include input/output stream functionality.


Q: What does cout do?

A: Outputs data to the console.


Q: What does cin do?

A: Takes input from the user.


Q: What symbol is used for comments in C++?

A: // for single-line, /* */ for multi-line.


Q: What is a pointer?

A: A variable that stores a memory address.


Q: What is a reference variable?

A: An alias for another variable.


Q: What is function overloading?

A: Multiple functions with the same name but different parameters.


Q: What is a class?

A: A user-defined data type with data members and methods.


Q: What is an object?

A: An instance of a class.


Q: What is inheritance?

A: When a class derives properties from another class.


Q: What is polymorphism?

A: The ability of a function or method to behave differently based on input.


Q: What keyword is used to define a class?

A: class


Q: What is the scope resolution operator?

A: :: — used to define methods outside the class.


Q: What is a constructor in C++?

A: A special method called automatically when an object is created.


Q: What is a destructor?

A: A method called automatically when an object is destroyed.


Q: What is the difference between public, private, and protected?

A: They define access levels of class members.


Q: What is a header file?

A: File containing function declarations and macros.


Q: What does namespace do?

A: Groups identifiers to avoid name conflicts.


Q: What is dynamic memory allocation?

A: Allocating memory during runtime using new or malloc.


Q: What is STL?

A: Standard Template Library — prebuilt C++ classes and functions.


Q: What is the difference between C and C++?

A: C++ supports OOP and has features like classes and templates, while C is procedural 

Comments