Home
Categories
Technology
Health
Education
Business
Lifestyle
News
Food & Reicipe
Entertainment
Travels and Tourism
Notes
Mock Test
Tools
Submit Study Materials
Pricing
About
Contact
Register
Login
3. Programming Language and Its Applications
1. Which of the following is not a valid token in C programming?
Keywords
Constants
Variables
Expressions
2. In C, which operator is used for dereferencing a pointer?
&
*
->
&&
3. Which of the following is true about a recursive function?
It always calls itself indefinitely
It must have a base case to terminate
It cannot be used in sorting algorithms
It only works for array manipulation
4. What is the result of the following expression in C: (x>y)?x:y?
Returns x if x is greater than y
Returns x if x is less than y
Returns y if x is greater than y
Returns y if x is less than y
5. What does the "sizeof" operator in C do?
Allocates memory dynamically
Returns the size of a data type or variable
Creates a new variable
Returns the address of a variable
6. What is the correct syntax for declaring a function in C?
returnType functionName()
functionName returnType()
returnType() functionName
functionName() returnType
7. Which of the following is true about arrays in C?
Array size must be constant and predefined
Arrays in C are dynamic in size
Array elements can only store integers
Arrays can be initialized after declaration
8. Which of the following is a feature of C pointers?
A pointer can point to any type of data
A pointer can only point to a variable of its own type
Pointers are not used in C
Pointers cannot hold addresses
9. What does the "&" operator do in C?
Returns the address of a variable
Dereferences a pointer
Allocates memory dynamically
Returns the value stored at an address
10. What is the output of the following C code: int arr[2] = 1, 2; and \text{printf("%d", arr[0]);}?
1
2
12
Error
11. Which of the following is the correct way to define a structure in C?
struct Name { int age; char gender; };
struct Name { int age, char gender; };
struct Name { int age, gender; };
struct Name { age, gender; };
12. Which of the following is true about unions in C?
A union can store multiple data types at once
A union can only store one member’s data at a time
A union is faster than a structure
A union does not need to be declared
13. What is the purpose of a function pointer in C?
To store the address of a function
To define a new function
To declare an inline function
To return a function’s value
14. What does the "return" keyword do in C?
Exits the program
Returns a value from a function
Transfers control to a function
Prints a value to the console
15. Which of the following is an example of file handling in C?
fopen()
malloc()
sizeof()
printf()
16. What is the output of the following C code: \text{printf("%d", 5 + 3 * 2);} ?
11
16
8
13
17. Which of the following is true about constructors in C++?
They are automatically called when an object is created
They are used to destruct objects
They are always defined with the "return" keyword
They are used to return values from a class
18. What is the main advantage of using function overloading in C++?
The same function name can perform different tasks
It allows passing multiple arguments to a function
It allows the function to return multiple values
It helps with memory optimization
19. Which of the following is used to implement polymorphism in C++?
Function Overloading
Constructor Overloading
Friend Functions
Operator Overloading
20. In C++, what does "this" pointer refer to?
It refers to the current instance of the class
It is used to access static members of the class
It is used for inheritance
It is used to access global variables
21. Which of the following access specifiers allows members to be accessed only within the same class?
Public
Private
Protected
Friend
22. Which of the following is true about a pure virtual function in C++?
It is declared in a base class and must be overridden in derived classes
It is declared in a derived class and cannot be overridden
It has a default implementation
It cannot be declared in the base class
23. Which of the following is true about exception handling in C++?
try block is used to catch exceptions
catch block is used to throw exceptions
throw block is used to catch exceptions
try block is used to throw exceptions
24. What does the term "template" refer to in C++?
A blueprint to create generic classes and functions
A library used for file operations
A method for creating exception handling blocks
A feature for managing memory dynamically
25. In C++, which of the following defines a template function?
template <typename T> void func(T a) { }
template <typename T> void func() { }
template <class T> void func() { }
All of the above
26. In C, which of the following is used to declare a constant value?
const
#define
static
Both A and B
27. What does the "fseek()" function do in C?
It moves the file pointer to a specific location
It opens a file
It reads data from a file
It closes a file
28. Which of the following is true about function overloading in C++?
It allows functions with the same name but different argument types
It allows functions to return multiple values
It can only be used for member functions
It can only be used with default arguments
29. What is the purpose of the "new" keyword in C++?
To allocate memory dynamically for an object
To define a new class
To initialize a pointer variable
To overload an operator
30. Which of the following is true about static members of a class in C++?
They are shared by all objects of the class
They belong to each object individually
They are always private
They cannot be accessed outside the class
31. Which of the following is true about exception handling in C++?
Exceptions must be caught using a try block
Exceptions can be rethrown in the catch block
Both A and B
Exceptions cannot be caught
32. Which of the following is true about passing a structure to a function in C?
Structures can be passed by value or by reference
Structures can only be passed by reference
Structures can only be passed by value
Structures cannot be passed to functions
33. What is the purpose of the "delete" operator in C++?
To deallocate memory allocated using "new"
To remove an element from a container
To delete a file from the system
To release the memory occupied by a function
34. Which of the following is an advantage of inheritance in C++?
It allows code reuse and the creation of hierarchical relationships
It makes the program slower
It allows function overloading only
It allows defining private functions
35. Which of the following is true about virtual functions in C++?
They allow dynamic method dispatch during runtime
They cannot be called directly
They are not inherited by derived classes
They are not part of the class hierarchy
36. What is the purpose of "friend" functions in C++?
To allow access to private and protected members of a class
To define multiple constructors
To create an alias for a class
To manage memory allocation
37. Which of the following is correct for file input operations in C?
fscanf() reads formatted input from a file
fread() reads binary data from a file
Both A and B
None of the above
38. What is the syntax for accessing an element of a structure in C?
structname.element
structname[element]
structname->element
Both A and C
39. Which of the following is true about a destructor in C++?
It is automatically called when an object goes out of scope
It is used to initialize object data members
It is called explicitly by the user
It has no return type
40. What is the output of the following C++ code? int a = 5; float b = 2.5; cout << a + b;
7.5
7
5.5
Error
41. Which of the following is true about the "this" pointer in C++?
It points to the current instance of the class
It is used to return the address of an object
It is automatically passed to every non-static member function
Both A and C
42. In C++, which function is called when an object is created?
Constructor
Destructor
Member Function
Friend Function
43. Which of the following is true about object slicing in C++?
It occurs when a derived class object is assigned to a base class object
It happens when a base class object is assigned to a derived class object
It occurs only with reference variables
It happens only with pointers
44. Which of the following is true about default arguments in C++?
They must be specified in the function declaration
They can only be specified in the function definition
They must be passed when calling the function
They can be omitted when calling the function
45. What is the result of the following operation in C: 5 / 2?
2.5
2
3
Error
46. Which of the following is used for input and output operations in C++?
cin and cout
scanf and printf
getchar and putchar
None of the above
47. Which of the following is used to allocate memory dynamically in C?
malloc()
calloc()
realloc()
All of the above
48. What is the purpose of a function template in C++?
To define a generic function that works with different data types
To create a function that takes multiple arguments of the same type
To define a function with a fixed number of arguments
To define a function that returns a value
49. In C++, which operator is used for memory allocation?
new
malloc()
calloc()
allocate()
50. Which of the following is a correct syntax for defining a class in C++?
class className { public: };
class className { private: };
class className { };
All of the above
51. Which of the following operators can be overloaded in C++?
Arithmetic operators
Comparison operators
Assignment operators
All of the above
52. What is the main advantage of using a destructor in C++?
It is used for cleaning up resources and freeing memory
It is used to initialize object properties
It can be used for function overloading
It is used for dynamic memory allocation
53. Which of the following is used to create an object of a class in C++?
new keyword
class constructor
class name
Both A and B
54. What does the "delete[]" operator do in C++?
Deallocates memory allocated to a pointer array
Deallocates memory allocated for a single object
Allocates memory for an array
Allocates memory for an object
55. Which of the following is true about inline functions in C++?
They are expanded at the place where they are called
They must have a return type
They can have multiple return statements
They cannot accept parameters
56. In C++, what does the term "friend class" mean?
A class that can access private and protected members of another class
A class that is related to another class through inheritance
A class that has the same member functions as another class
A class that can only access public members of another class
57. Which of the following is true about file handling in C?
fopen() is used to open a file
fclose() is used to close a file
fseek() is used to move the file pointer
All of the above
58. What is the main difference between a structure and a union in C?
A structure can store multiple data types at once, while a union stores only one data type at a time
A structure stores only integers, while a union stores different data types
A structure is used to define objects, while a union is used to define functions
A structure does not require memory allocation, while a union does
59. In C++, what is the default access specifier for members of a class?
public
private
protected
friend
60. Which of the following is a feature of dynamic memory allocation in C?
Memory can be allocated and deallocated during runtime
It allows for manual memory management
It helps prevent memory overflow
Both A and B
61. What is the output of the following C++ code? int arr[2] = 5, 10; cout << arr[1];
5
10
15
Error
62. Which of the following is used to read a character from the keyboard in C?
getchar()
getch()
scanf()
cin
63. What is the default behavior of the "new" keyword in C++ when allocating memory?
It initializes the memory with zero
It initializes the memory with garbage values
It automatically frees the memory after use
It checks for memory leaks
64. Which of the following is the correct syntax for accessing a member of a class object in C++?
object.member
object->member
class.member
Both A and B
65. In C, what is the correct syntax to declare a function that returns an integer and takes no parameters?
int func()
func() int
int func(void)
Both A and C
66. Which of the following is a type of loop in C?
for loop
while loop
do-while loop
All of the above
67. Which of the following is true about a copy constructor in C++?
It is called when an object is initialized with another object of the same class
It creates a new object by copying the data from an existing object
Both A and B
None of the above
68. What is the main purpose of the "throw" keyword in C++?
To raise an exception
To catch an exception
To define a function template
To pass arguments to a function
69. Which function in C++ is used to allocate memory for a single object dynamically?
malloc()
calloc()
new
alloc()
70. In C++, which type of constructor is called when an object is created with no arguments?
Default constructor
Copy constructor
Parameterized constructor
Destructor
71. Which of the following is correct for passing an array to a function in C?
Arrays are passed by value
Arrays are passed by reference
Arrays are passed by address
Arrays cannot be passed to functions
72. Which of the following is an example of a pure virtual function in C++?
A function with an implementation in the base class
A function that must be overridden in a derived class
A function without a body in the base class
A function with a static member
73. In C++, what is the result of dividing an integer by zero?
Undefined behavior
0
Error message
Exception thrown
74. What is the main purpose of the 'this' pointer in C++?
It points to the current object of the class
It points to the parent class object
It stores the address of the function
It points to the memory location of an array
75. Which operator is used to access a class member using a pointer in C++?
. (dot)
-> (arrow)
& (address)
* (dereference)
76. Which of the following is true about polymorphism in C++?
It allows a function to have different behaviors based on the object
It is used to initialize object data members
It is only applicable to operators
It can only be used in function templates
77. In C++, which of the following statements is correct about destructors?
A destructor has the same name as the class
A destructor can take parameters
A destructor is called explicitly by the user
A destructor is used to initialize object data members
78. Which of the following types can be used as function arguments in C++?
int
float
object of a class
All of the above
79. Which of the following is the correct syntax for a reference variable in C++?
&var
*var
var&
var*
80. Which of the following is correct for memory allocation in C++?
malloc() and free() are used for dynamic memory allocation
new and delete are used for dynamic memory allocation
new and delete[] are used for array memory allocation
Both B and C
81. What is the output of the following code in C++? int arr[3] = 5, 10, 15; cout << arr[1];
5
10
15
50
82. Which of the following is true about function overloading in C++?
Functions with the same name but different parameter types can be overloaded
Functions can be overloaded by return type only
Function overloading is not allowed in C++
Functions can be overloaded only by their names
83. What does the "sizeof" operator do in C and C++?
It returns the size of a variable or data type
It returns the value of the variable
It returns the address of the variable
It frees the memory allocated for a variable
84. Which of the following is true about "try" and "catch" blocks in C++?
A try block must be followed by at least one catch block
A catch block can only handle exceptions of the same type
Multiple catch blocks cannot be used
Both A and B
85. Which of the following is true about inheritance in C++?
Derived classes inherit both public and private members of a base class
Inheritance allows the reuse of code from the base class
A class can only inherit from one base class
Inheritance can only be single
86. Which of the following statements is true about arrays in C?
Arrays can be passed to functions by reference
Arrays can be resized at runtime
Array elements are stored in non-contiguous memory locations
Arrays can only hold one data type
87. Which of the following is true about a constructor in C++?
It is automatically called when an object is created
It can be explicitly called in the main function
It can have a return type
It must be declared as static
88. What is the purpose of the "void" keyword in C++?
It represents a function that does not return a value
It represents an undefined type
It is used for memory allocation
It represents an object of no specific type
89. Which of the following is correct about the scope of a variable in C and C++?
A variable declared inside a function has local scope
A variable declared inside a loop has global scope
A variable declared outside all functions has local scope
A variable declared inside a class has function scope
90. Which of the following is true about static members of a class in C++?
They are shared by all objects of the class
They are only accessible through an instance of the class
They cannot be modified
They can only be accessed within the constructor
91. Which of the following is true for the malloc() function in C?
It initializes memory to zero
It allocates memory for a specified size
It can only allocate memory for single data types
It can be used only with pointers
92. What does the const keyword do in C++ when applied to a member function?
Prevents the function from modifying the object
Makes the member function private
Indicates the function can return constant data
Marks the member function as static
93. In C++, which of the following is true about a virtual destructor?
It is necessary only in case of multiple inheritance
It is automatically invoked when an object is destroyed
It prevents the derived class destructor from being called
It must be defined as static
94. Which of the following is a feature of the new operator in C++?
It can be overloaded
It requires the use of delete to free memory
It only allocates memory for primitive data types
It returns NULL if memory allocation fails
95. Which of the following is true about the friend keyword in C++?
It allows access to private and protected members of the class
It allows classes to inherit from each other
It restricts a class from being inherited
It is used to define constant functions
96. What is the result of calling the delete[] operator on a pointer to a single object in C++?
Undefined behavior
Memory is freed for the object
No memory is freed
Memory is freed for the object and all its members
97. In C++, what is the main difference between a struct and a class?
struct members are by default private, while class members are public
class members are by default private, while struct members are public
struct allows inheritance, but class does not
struct can only contain integers, while class can contain any data type
98. What is the purpose of a this pointer in C++?
It points to the current object of the class
It points to a static member of the class
It stores the address of the current function
It is used for dynamic memory allocation
99. In C++, what is the main purpose of the operator keyword?
It allows overloading of operators for custom behavior
It defines constant member functions
It marks functions as private
It is used to declare templates
100. What is the size of a bool in C++?
1 byte
2 bytes
4 bytes
8 bytes
101. Which of the following is a valid way to access a member of a structure using a pointer in C?
structure->member
structure.member
*structure.member
structure&member
102. What is the output of the following code in C++? int x = 10; cout << ++x;
10
11
Error
Undefined behavior
103. Which of the following is used to store a value that is constant in C++?
constant
static
final
const
104. In C++, what does the term "dynamic binding" refer to?
The process of linking a function call to the function definition at runtime
The process of determining the type of an object at compile time
The process of linking a member function to its object
The process of allocating memory dynamically
105. Which of the following is true about function overloading in C++?
The functions must have the same name but different return types
The functions must have different names
The functions must have the same number of arguments
The functions must have different parameter types
106. In C++, which of the following is the correct way to allocate memory for an array of 10 integers using new?
int arr = new int[10];
int arr(10) = new int[];
int* arr = new int[10];
int arr[10] = new int;
107. What is the default access specifier for members of a class in C++?
public
private
protected
friend
108. Which of the following is the correct way to define a pure virtual function in C++?
virtual void func() = 0;
void func() = 0;
func() { return 0; }
void func() { }
109. Which of the following describes the concept of "destructor" in C++?
A destructor is automatically called when an object is created
A destructor is called explicitly by the user to delete an object
A destructor is called when the object goes out of scope
A destructor is used to initialize object data members
110. In C++, which type of function allows you to specify default arguments?
Member function
Constructor
Destructor
Non-member function
111. Which of the following C++ features is used to define a template for a function that works with different data types?
Operator overloading
Function overloading
Function templates
Member templates
112. What is the correct syntax for declaring a pointer to an integer in C?
int *ptr;
pointer int ptr;
int ptr*;
int ptr;
113. Which of the following operators is used for memory allocation in C?
malloc()
alloc()
new()
create()
114. In C++, what is the purpose of the explicit keyword in front of a constructor?
It prevents implicit conversions from other types
It ensures the constructor is only used once
It makes the constructor private
It prevents a constructor from being called directly
115. Which of the following is true about function pointers in C and C++?
A function pointer can be assigned to point to a function and called indirectly
A function pointer cannot be passed to another function
Function pointers can only point to functions that return integers
Function pointers cannot be used in recursive functions
116. Which of the following keywords is used in C++ to prevent a function from being overridden in a derived class?
final
override
static
const
117. What does the sizeof() operator return in C and C++?
The memory address of the variable
The number of elements in an array
The size (in bytes) of a data type or object
The number of bytes left in memory
118. Which of the following describes "dynamic memory allocation" in C?
Memory is allocated before the program runs
Memory is allocated for the entire program at once
Memory is allocated during program execution
Memory is allocated using the new operator
119. In C++, which of the following can be used to define a constant member variable?
const keyword
static keyword
final keyword
constant keyword
120. Which of the following is an example of function overloading in C++?
Two functions with the same name but different parameter types
A function with a different return type
A function that returns a constant value
A function with a different name
121. In C++, what is the result of trying to call a non-virtual function in a derived class using a base class pointer?
It calls the base class version of the function
It causes a runtime error
It calls the derived class version of the function
It results in undefined behavior
122. Which of the following is the correct syntax for defining an array of structures in C?
struct ArrayName[10];
struct ArrayName { }[10];
struct ArrayName[10] = { };
struct { } ArrayName[10];
123. Which of the following allows you to create an object at runtime in C++?
new operator
malloc() function
calloc() function
alloc() function
124. In C++, what is the result of calling a constructor with arguments when no matching constructor is defined in a class?
Compiler error
The default constructor is called
A runtime exception occurs
The program exits without any error
125. What is the difference between struct and class in C++?
A struct has default private access, while a class has default public access
A struct is used for objects, and a class is used for data
A struct cannot have member functions, but a class can
There is no difference, both are used in the same way
126. Which C++ keyword is used to define a class method that can only be accessed through an object?
static
inline
friend
virtual
127. Which of the following is true about polymorphism in C++?
It allows objects of different classes to be treated as objects of a common base class
It allows functions to be executed based on the class object type
It can be applied to only base class functions
Both A and B
128. What is the purpose of a static function in C++?
It restricts the function to be used only inside the class
It allows the function to be shared among all objects of the class
It defines the function as private
It allows the function to be inherited
129. Which of the following is the correct syntax to create a reference to an integer variable in C++?
int& ref = x;
int& ref = &x;
int* ref = x;
ref = x;
130. Which of the following is the correct way to call a function in C++ using a reference argument?
function(ref);
function(*ref);
function(ref*);
function(&ref);
131. Which of the following functions in C++ can be used to allocate memory for an array of objects dynamically?
new[]
malloc[]
calloc[]
alloc()
132. Which of the following is true about the scope of variables in C++?
Variables declared inside a function are local to that function
Variables declared inside a class are local to that class
Variables declared inside a loop have global scope
Global variables cannot be accessed inside functions
Check Score
Results