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
-
True
-
False
-
Invalid Statement
-
None of the Above
-
The snippet is illegal
-
It loops forever
-
It is ignored by compiler, but it is not illegal
-
None of the Above
-
sin()
-
kbhit()
-
tmpnam()
-
None of the Above
B
Correct answer
Explanation
kbhit() is a non-standard DOS/Windows function from conio.h that checks if a key has been pressed. sin() is a standard math function, and tmpnam() is a standard C/C++ function for generating temporary filenames. ANSI C++ does not include kbhit().
-
No
-
Case sensitivity is compiler-determined
-
Yes
-
None of the Above
C
Correct answer
Explanation
C++ is case-sensitive, meaning identifiers like 'Main', 'main', and 'MAIN' are treated as completely different symbols. This applies to variable names, function names, keywords, and all other identifiers. The compiler distinguishes strictly by character case.
-
Yes
-
No
-
Only optimized compilers will compile C++ code.
-
None of the Above
B
Correct answer
Explanation
C compilers are designed to compile C code only. C++ includes additional features like classes, templates, and function overloading that C compilers do not understand. C++ code must be compiled with a C++ compiler that supports these language extensions.
-
The snippet is illegal
-
It loops forever
-
It is ignored by compiler, but it is not illegal
-
None of the Above
B
Correct answer
Explanation
The syntax for(;;) ; is a valid C/C++ statement. The empty conditions in the for loop default to true, and the trailing semicolon represents an empty loop body, causing the program to loop infinitely.
-
Copies "This" into an_array
-
Adds "This" to the end of an_array
-
Compares an_array and "This"
-
None of the Above
B
Correct answer
Explanation
To understand what the code strcat(an_array, "This") does, we need to know that strcat() is a function in C language that concatenates (joins) two strings.
The function takes two arguments: the first argument is the destination array (where the concatenated string will be stored), and the second argument is the source string (which will be concatenated to the destination array).
In this case, the function call strcat(an_array, "This") concatenates the string "This" to the end of the string already stored in an_array. Therefore, the correct option is:
The Answer is: B. Adds "This" to the end of an_array
-
Breaks out of the if statement
-
Exits the function
-
Nothing (Compiler error)
-
None of the Above
C
Correct answer
Explanation
The break statement can only be used inside loops (for, while, do-while) or switch statements. Using break inside an if statement that is not contained in a loop or switch is a compilation error. The code attempts to break from just an if block, which is invalid.
-
int main()
-
int main(int argc, char *argv[])
-
They both work
-
None of the Above
C
Correct answer
Explanation
Both 'int main()' and 'int main(int argc, char *argv[])' are valid declarations for main() in C and C++. The first is for programs without command-line arguments, the second for programs that need to process command-line arguments. Both are standard and correct.
B
Correct answer
Explanation
ERROR is NOT an internal SAS variable used to mark errors within a dataset. The correct automatic variable is ERROR (with one underscore on each side), which is set to 1 when an error occurs during DATA step execution. However, the question asks about it being used to mark errors 'within a dataset', which is misleading - it marks DATA step execution errors, not dataset-specific errors.
-
Character
-
Date
-
Integer
-
RAW
D
Correct answer
Explanation
RAW datatype in Informatica represents binary data and cannot be implicitly or explicitly converted to other datatypes like string, number, or date. RAW data must be handled as binary - attempting conversion will cause errors. Character, Date, and Integer can all be converted to each other using appropriate conversion functions like TO_CHAR, TO_DATE, or TO_INTEGER.
-
IN,OUT
-
OUT,OUT
-
IN ,IN
-
OUT,IN
B
Correct answer
Explanation
In Oracle Apps concurrent programs, errbuf and retcode are both OUT parameters - errbuf returns error messages and retcode returns completion status codes. Options A, C, and D incorrectly specify IN parameters.
B
Correct answer
Explanation
Fields and properties cannot share the same name in the same scope. They would conflict - the property would typically wrap the field with a different name (e.g., private field _name, public property Name).
A
Correct answer
Explanation
Properties are language constructs that work at compile time for type checking and code generation, and at runtime for executing getter/setter logic. Both phases are involved in property behavior.
C
Correct answer
Explanation
string is a class in C++ (std::string), NOT a basic data type. The basic types are int, char, float, double, bool, and wchar_t. string is part of the Standard Library and provides string manipulation functionality.