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
-
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.
-
thread
-
node
-
both a and b
-
none of the above
C
Correct answer
Explanation
In Ab Initio, declare pages can be of both thread and node types. This flexibility allows declare pages to be used in different parallel processing contexts - thread-level for shared memory operations and node-level for distributed processing across partitions.
A
Correct answer
Explanation
In RPG/400 programming, arrays are declared in the E-spec (Extension specification). The E-spec is specifically designed for defining array characteristics including dimensions, and element sizes. Other specs like I (Input), F (File), or C (Calculation) serve different purposes.
C
Correct answer
Explanation
RPG/400 programs can use a maximum of 254 subroutines. This is a built-in limitation of the language. The 'Unlimited' option is incorrect as RPG/400 has specific maximum limits for various program elements including subroutines.
D
Correct answer
Explanation
RPG/400 programs can declare a maximum of 200 arrays. This is a specific limit within the language that programmers need to be aware of when designing data-intensive applications. The limit is higher than file limits because arrays are memory structures rather than file I/O objects.
-
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
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).