Computer Knowledge
Programming Fundamentals
2,381 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
-
Large number of Compound operators
-
Function and data pointers supporting
-
Small set of key words
-
Automatic garbage collection
D
Correct answer
Explanation
C does not have automatic garbage collection; developers must manage memory manually using malloc and free. Other features like compound operators, pointers (data and function), and a small keyword footprint are core characteristics of C.
A
Correct answer
Explanation
To solve this question, the user needs to know about pointers in programming languages. A pointer is a variable that stores the memory address of another variable. The symbol used to declare a pointer variable is the asterisk symbol (*), thus option A is the correct answer.
Option A: * is the correct symbol to declare a pointer variable.
Option B: - is not used to declare a pointer variable.
Option C: + is not used to declare a pointer variable.
Option D: | is not used to declare a pointer variable.
The Answer is: A
-
True
-
False
-
Cannot continuously increment a variable
-
It depends on the variable type
D
Correct answer
Explanation
Integer overflow behavior depends on the data type. Signed integers wrap around and become negative when incremented beyond their maximum value (e.g., 127+1=-128 for byte). Unsigned integers wrap to zero. The question tests understanding of type-specific overflow behavior.
-
The first argument passed into the program
-
You can't define main like that
-
The program name
-
Null value
C
Correct answer
Explanation
In C and C++, the argv array contains command-line arguments, where argv[0] is conventionally the path or name of the program being executed. Subsequent indices hold the actual arguments passed.
-
SETLL
-
SETGT
-
Both 1 & 2
-
Neither 1 nor 2
C
Correct answer
Explanation
Both SETLL (Set Lower Limit) and SETGT (Set Greater Than) are positioning operations in RPG/400 that act as pointers to specific records in a file. SETLL positions at the first record greater than or equal to a key, while SETGT positions at the first record greater than a key. Both are pointer operations used for record positioning.
-
SETLL + READP
-
SETGT + READP
-
SETLL + READE
-
SETGT + READE
C
Correct answer
Explanation
In RPG, the CHAIN operation combines the positioning and reading capabilities of SETLL (Set Lower Limit) to locate a record and READE (Read Equal Key) to retrieve it. Options using READP are wrong because they read prior records rather than matching keys.
B
Correct answer
Explanation
In the expression i==3 || j++, the left operand of the logical OR operator (i==3) evaluates to true. Due to short-circuit evaluation, the right operand (j++) is never evaluated, so j remains 4. Thus, printing j will output 4, making the statement that it prints 5 false.
B
Correct answer
Explanation
Using fflush(stdin) is undefined behavior according to the C standard, which specifies that fflush is only defined for output streams. While some compilers (like MSVC) allow it as an extension, it is not portable across standard-compliant platforms.
A
Correct answer
Explanation
In C function parameter declarations, array notation always decays to a pointer. When you write 'int a[5]' as a function parameter, it is automatically converted to 'int *a' by the compiler. The array size (5 in this case) is ignored - the compiler only cares that it's a pointer to an integer. This is why array parameters don't carry size information.
B
Correct answer
Explanation
In C (but not C++), casting the return value of malloc is unnecessary because void* automatically converts to any pointer type. In fact, explicit casting can hide errors if you forget to include stdlib.h. The cast is only necessary in C++ or when compiling C code with a C++ compiler.
-
Raise Application procedure
-
Raise Application Error procedure
-
Application Error procedure
-
None of the Above
B
Correct answer
Explanation
In PL/SQL, RAISE_APPLICATION_ERROR (represented here as Raise Application Error) is the standard built-in procedure used to issue user-defined error messages from stored subprograms. The other options are incorrect or generic names that do not exist as built-in PL/SQL procedures for this purpose.
B
Correct answer
Explanation
In PL/SQL, a function must return exactly one value, not zero or more. A procedure does not return a value to its calling environment (it can have OUT parameters, but that's different from a return value). The statement reverses the correct definitions, making it false.
-
The package itself cannot be called, parameterized, or nested.
-
The format of a package is similar to that of a subprogram.
-
The contents can be shared by many applications once written.
-
None of the above.
D
Correct answer
Explanation
Option A is correct: packages cannot be called or nested like subprograms. Option B is correct: packages have a two-part format (specification and body) similar to subprograms. Option C is correct: packages are designed for code reuse across applications. Since all statements A-C are true, 'None of the above' is the false statement.
-
A loop that functions infinitely well
-
A loop that runs forever
-
A loop that never starts
-
A loop that will never function
B
Correct answer
Explanation
An infinite loop is a loop that executes indefinitely without terminating. Option B correctly defines this. Option A describes a well-functioning loop (not necessarily infinite). Option C describes a loop that never starts (not infinite). Option D describes a non-functional loop (different concept).