Computer Knowledge
Programming Fundamentals
2,611 Questions
Programming fundamentals form the core logic of software development and computer science. This includes variable declarations, pointer assignments, loop iterations, and exception handling. These technical topics are regularly tested in computer knowledge and IT officer competitive examinations.
Variables and arraysPointer assignmentsLoop iterationsException handling blocksCompile time errorsFunction references
Programming Fundamentals Questions
-
the first line of the class
-
the main function
-
the first executable method of the class
-
none of the above
B
Correct answer
Explanation
In C++, the main() function is the designated entry point where program execution begins. The first line of a class is not executable code itself, and 'first executable method' is ambiguous since main() is a global function, not a class method.
-
same variable is accessed in called function
-
new variable is accessed in called function
-
new object is created in memory
-
both (2) and (3)
D
Correct answer
Explanation
When passing arguments by value, a new copy of the variable is created and a new object is allocated in memory for the called function. The original variable remains unchanged in the caller's scope, so both statements (2) and (3) about new variable access and new object creation are correct.
-
is initialized by constant
-
is not initialized.
-
does not exist in C language
-
only takes 'int' values
-
works like null pointer
B
Correct answer
Explanation
A pointer which is not initialized in C, is known as Wild Pointer.
-
strspn();
-
strnset();
-
strnsetu();
-
strdup();
-
strncpyk();
A
Correct answer
Explanation
This option is true because this function takes two arguments, and it returns the position of the string from where the source array doesn’t match with the target one. Format of this function is :-Strspn( string 1, string 2). For example, suppose we enter first string as “good morning” and second string as “good luck”. So, the function will return 5 because after 5 characters there is no match found in the strings. So, this is correct.
-
contains no data until a call for it is made
-
is an object that is mapped to a SELECT sentence
-
both (1) and (2)
-
none of these
C
Correct answer
Explanation
A VIEW is a virtual table based on the result-set of a SELECT query. It contains no stored data itself - data is generated dynamically when the view is queried. Option C correctly captures both characteristics: views don't store data (option A) and are mapped to SELECT statements (option B).
-
Static variable
-
Reference variable
-
Automatic variable
-
Global variable
-
Pointer variable
B
Correct answer
Explanation
This type of variable in C++ must be initialised at the time of declaration.
D
Correct answer
Explanation
This is a manipulator in C++ used to format the data display.
-
Array
-
Functions
-
Enumeration
-
Structure
-
Union
C
Correct answer
Explanation
This data type in C++ provides a way for attaching names to numbers, thereby increasing comprehensibility of the code.
C
Correct answer
Explanation
This member dereferencing operator is used to access a member using a pointer to the object and a pointer to that member.
-
Class declaration
-
Class member function definition
-
Preprocessor directives
-
The main() function program
-
The closing of the main() program
C
Correct answer
Explanation
This part in general structure of C++ program comes first while writing a program in C++.
-
strcat()
-
strlwr()
-
strrev()
-
strupr()
-
strlen()
D
Correct answer
Explanation
This string handling function in C++ is used to convert a string into upper case.
-
Assign NULL value to the next pointer field of the new node.
-
Assign address of the new node to start.
-
Both (1) & (2)
-
None of these
C
Correct answer
Explanation
Inserting at the end of a linked list involves two key steps: setting the new node's next pointer to NULL (since it will be the last element), and updating the previous last node's next pointer to point to the new node. Both operations are necessary to properly maintain list integrity.
C
Correct answer
Explanation
A compiler translates source code into object code, which is stored in object files (.obj on Windows, .o on Unix-like systems). These object files contain machine code but may not be fully linked - they may reference external symbols that the linker will resolve. The .exe file is produced by the linker, not the compiler.
-
Stack
-
Queue
-
Circular queue
-
None of these
A
Correct answer
Explanation
Stacks are fundamental to recursive expression evaluation in compilers. Each recursive call pushes a new activation record containing local variables and return addresses. The Last-In-First-Out (LIFO) nature of stacks matches the call-return pattern of recursion.