1. Which of the following best describes encapsulation in object-oriented programming? A) Exposing all fields of a class for easy access B) Combining data and methods that operate on that data into a single unit and restricting access to some of the object’s components C) Inheriting behaviour from multiple parent classes D) Writing only static
Q1. In OOP, “inheritance” primarily promotes which key concept? A) Encapsulation B) Code reusability C) Data hiding D) Overloading Answer: B) Code reusability Q2. The class that is inherited from another class is called: A) Parent class B) Base class C) Derived class D) Subclass Answer: B) Base class Q3. The class that inherits another
1. In object-oriented programming, what does the term “instantiation” refer to? A) The process of defining a class B) The process of copying a function C) The process of creating an object from a class D) The process of compiling code Answer: C 2. What is created when a class is instantiated in Java? A)
1. In Object-Oriented Programming, an object is best described as: A) A function performing a specific task B) A self-contained unit consisting of data and methods C) A library containing multiple functions D) A syntax rule for defining a class Answer: B) 2. Which of the following represents the state of an object? A) Methods
1. Which of the following best defines a class in OOP? A) A collection of variables only B) A function that executes specific tasks C) A blueprint or template for creating objects D) A data type with no behavior Answer: C) A blueprint or template for creating objects 2. In OOP, what is an instance
1. Which of the following symbols is used to indicate a preprocessor directive in C? A) @ B) # C) $ D) % Answer: B 2. The #define directive in C is used for: A) Declaring a function B) Defining a macro or symbolic constant C) Including header files D) Declaring global variables Answer: B
1. Which of the following parameters are used in the main function to handle command line arguments in C? A) int argc, char *argv B) int argn, char **arglist C) int argc, char argv D) void argc, char *argv Answer: A 2. What does argc represent in a C program’s main function? A) Number of
1. Which header file is required for file handling in C? A) <stdio.h> B) <conio.h> C) <stdlib.h> D) <string.h> Answer: A 2. Which of the following modes opens a file for reading only? A) “w” B) “r” C) “a” D) “rw” Answer: B 3. What is the return type of fopen() function? A) int B)
1. Which of the following is the correct syntax to declare a function in C? A) return_type function_name(); B) function_name return_type(); C) function_name(); return_type D) return_type = function_name(); Answer: A 2. A function that calls itself is known as: A) Recursive Function B) Iterative Function C) Inline Function D) Macro Function Answer: A 3. What
1. Which of the following correctly declares a pointer to an integer in C? A) int p; B) int *p; C) int &p; D) int p*; Answer: B 2. What is the output of the following code? int x = 10; int *p = &x; printf(“%d”, *p); A) Address of x B) 10 C) Garbage