Q1. Which programming language is known as the ‘mother of all modern programming languages’?
A) FORTRAN
B) Pascal
C) C Language
D) COBOL
✅ Answer: C) C Language
💡 Explanation: C language (1972, Dennis Ritchie) is the foundation for C++, Java, C#, Python, and most modern languages.
──────────────────────────────────────────────────────────────────────────────────────────
Q2. In Java, what is ‘bytecode’?
A) Machine code for Intel CPUs
B) Intermediate code executed by the Java Virtual Machine (JVM)
C) Source code written in Java
D) Binary code for embedded systems
✅ Answer: B) Intermediate code executed by the Java Virtual Machine (JVM)
💡 Explanation: Java compiles to platform-independent bytecode, which JVM interprets on any OS — enabling ‘Write Once, Run Anywhere.’
──────────────────────────────────────────────────────────────────────────────────────────
Q3. Python is an example of a:
A) Compiled language only
B) Interpreted, high-level, dynamically-typed language
C) Low-level assembly language
D) Statically-typed compiled language
✅ Answer: B) Interpreted, high-level, dynamically-typed language
💡 Explanation: Python is interpreted (runs line by line), high-level (readable syntax), and dynamically typed (no explicit type declaration).
──────────────────────────────────────────────────────────────────────────────────────────
Q4. Which concept in C++ allows functions/operators to have the same name with different parameters?
A) Overriding
B) Polymorphism
C) Overloading
D) Encapsulation
✅ Answer: C) Overloading
💡 Explanation: Function/operator overloading allows multiple functions with the same name but different parameter types or counts.
──────────────────────────────────────────────────────────────────────────────────────────
Q5. What is the difference between a compiler and an interpreter?
A) Compiler is faster to write, interpreter is slower
B) Compiler translates entire source to machine code at once; interpreter translates line by line
C) No difference
D) Compiler is only for C, interpreter only for Python
✅ Answer: B) Compiler translates entire source to machine code at once; interpreter translates line by line
💡 Explanation: Compiler produces executable machine code in one pass. Interpreter reads and executes source code line by line.
──────────────────────────────────────────────────────────────────────────────────────────
Q6. In C, ‘malloc()’ is used for:
A) Mathematical calculations
B) Dynamic memory allocation at runtime
C) Matrix multiplication
D) Memory deallocation
✅ Answer: B) Dynamic memory allocation at runtime
💡 Explanation: malloc() (memory allocation) allocates a specified number of bytes in heap memory at runtime and returns a pointer.
──────────────────────────────────────────────────────────────────────────────────────────
Q7. What does ‘inheritance’ in OOP allow?
A) A class to hide its data
B) A class (child) to acquire properties and methods of another class (parent)
C) Objects to change type at runtime
D) Functions to have multiple definitions
✅ Answer: B) A class (child) to acquire properties and methods of another class (parent)
💡 Explanation: Inheritance allows a child/derived class to reuse and extend the properties and methods of a parent/base class.
──────────────────────────────────────────────────────────────────────────────────────────
Q8. In Python, which of the following correctly defines a lambda function?
A) def lambda x: x*2
B) lambda = x: x*2
C) lambda x: x*2
D) function(x): x*2
✅ Answer: C) lambda x: x*2
💡 Explanation: Python lambda syntax: lambda arguments: expression. Example: lambda x: x*2 creates an anonymous function.
──────────────────────────────────────────────────────────────────────────────────────────
Q9. Which keyword in Java is used to handle exceptions?
A) error
B) catch
C) handle
D) rescue
✅ Answer: B) catch
💡 Explanation: Java uses try-catch-finally blocks. ‘catch’ handles specific exceptions thrown within the try block.
──────────────────────────────────────────────────────────────────────────────────────────
Q10. Recursion in programming refers to:
A) Calling multiple functions at once
B) A function that calls itself
C) A loop that runs indefinitely
D) Running code in reverse
✅ Answer: B) A function that calls itself
💡 Explanation: Recursion is when a function calls itself with a modified argument until a base case is reached.
──────────────────────────────────────────────────────────────────────────────────────────
Q11. In C language, the ‘pointer’ is:
A) A variable that stores the address of another variable
B) A function return value
C) A conditional statement
D) A type of loop
✅ Answer: A) A variable that stores the address of another variable
💡 Explanation: A pointer variable stores the memory address of another variable, enabling direct memory manipulation in C.
──────────────────────────────────────────────────────────────────────────────────────────
Q12. What is ‘garbage collection’ in Java?
A) Deleting unused files from hard disk
B) Automatic memory management that frees memory occupied by unreachable objects
C) Removing syntax errors
D) Cleaning temporary build files
✅ Answer: B) Automatic memory management that frees memory occupied by unreachable objects
💡 Explanation: Java’s garbage collector automatically identifies and frees heap memory from objects no longer referenced by the program.
──────────────────────────────────────────────────────────────────────────────────────────
Q13. What does ‘static’ keyword mean in Java?
A) Variable value cannot change
B) Member belongs to the class rather than any instance
C) Method runs faster
D) Variable is stored in stack
✅ Answer: B) Member belongs to the class rather than any instance
💡 Explanation: Static members (variables/methods) belong to the class itself, shared across all instances, and can be accessed without an object.
──────────────────────────────────────────────────────────────────────────────────────────
Q14. Which programming paradigm treats functions as first-class citizens?
A) Procedural Programming
B) Object-Oriented Programming
C) Functional Programming
D) Structured Programming
✅ Answer: C) Functional Programming
💡 Explanation: Functional programming treats functions as first-class citizens — they can be passed as arguments, returned, or assigned to variables.
──────────────────────────────────────────────────────────────────────────────────────────
Q15. In Python, which data structure allows duplicate values and maintains insertion order?
A) Set
B) Dictionary
C) List
D) Frozenset
✅ Answer: C) List
💡 Explanation: Python Lists are ordered, mutable, and allow duplicate values. Sets don’t allow duplicates; dicts maintain key order (Python 3.7+).
──────────────────────────────────────────────────────────────────────────────────────────
Q16. What does API stand for?
A) Application Programming Interface
B) Automated Program Integration
C) Application Process Input
D) Advanced Programming Index
✅ Answer: A) Application Programming Interface
💡 Explanation: API (Application Programming Interface) defines rules for how software components communicate with each other.
──────────────────────────────────────────────────────────────────────────────────────────
Q17. The time complexity of linear search in worst case is:
A) O(1)
B) O(log n)
C) O(n)
D) O(n²)
✅ Answer: C) O(n)
💡 Explanation: Linear search checks each element one by one. Worst case (element at end or not present) requires n comparisons = O(n).
──────────────────────────────────────────────────────────────────────────────────────────
Q18. ‘JVM’ in Java stands for:
A) Java Variable Machine
B) Java Virtual Machine
C) Java Verification Module
D) Java Version Manager
✅ Answer: B) Java Virtual Machine
💡 Explanation: JVM (Java Virtual Machine) is the runtime environment that executes Java bytecode, providing platform independence.
──────────────────────────────────────────────────────────────────────────────────────────
Q19. Which Python library is most used for data science and machine learning?
A) Django
B) Flask
C) NumPy and Pandas
D) Tkinter
✅ Answer: C) NumPy and Pandas
💡 Explanation: NumPy provides numerical arrays/math; Pandas provides DataFrames for data manipulation — both are fundamental in data science.
──────────────────────────────────────────────────────────────────────────────────────────
Q20. What is ‘type casting’ in programming?
A) Assigning a type to a variable permanently
B) Converting a variable from one data type to another
C) Casting an object to a class method
D) Defining variable types automatically
✅ Answer: B) Converting a variable from one data type to another
💡 Explanation: Type casting converts a value from one data type to another (e.g., int to float, float to int) explicitly or implicitly.
──────────────────────────────────────────────────────────────────────────────────────────