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

Multiple choice technology programming languages
  1. (1) Dynamic entry point

  2. (2) Alternate entry point

  3. (3) Static entry point

  4. (4) Normarl enrty Point

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

To answer this question, the user needs to know about COBOL programs, entry points, and the use of the ENTRY label.

The ENTRY label in a COBOL program is used to specify another entry point at which a program will begin running. This allows the program to be executed from different starting points within the same program. The use of an alternate entry point enables a program to be divided into smaller, more manageable components.

Now, let's go through each option and explain why it is right or wrong:

A. (1) Dynamic entry point: This option is incorrect. Dynamic entry point refers to the ability of a program to call another program or subroutine at run time, rather than at compile time.

B. (2) Alternate entry point: This option is correct. The use of the ENTRY label in a COBOL program specifies an alternate entry point at which a program will begin running.

C. (3) Static entry point: This option is incorrect. A static entry point is a fixed starting point within a program that is determined at compile time.

D. (4) Normal entry point: This option is incorrect. There is no such term as a normal entry point in COBOL programming.

Therefore, the answer is: B. (2) Alternate entry point

Multiple choice technology programming languages
  1. (1) C/C++-to-COBOL programs calls

  2. (2) COBOL-to-C/C++ programs calls

  3. (3) COBOL-to-COBOL programs calls

  4. (4) C/C++-to-C/C++ programs calls

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To answer this question, the user needs to know the difference between procedure pointers and function pointers and their respective use cases.

A function pointer is a pointer that points to a function. It can be used to call the function that it points to. A procedure pointer, on the other hand, is a pointer that points to a procedure. A procedure is similar to a function but does not return a value.

Now, let's go through each option and see which one is correct:

A. (1) C/C++-to-COBOL programs calls: This option is incorrect. Procedure pointers are not typically used in C/C++-to-COBOL programs calls. Instead, function pointers are used for this type of program.

B. (2) COBOL-to-C/C++ programs calls: This option is incorrect. Procedure pointers are not typically used in COBOL-to-C/C++ program calls. Instead, function pointers are used for this type of program.

C. (3) COBOL-to-COBOL programs calls: This option is correct. Procedure pointers are more efficient than function pointers for COBOL-to-COBOL program calls. This is because COBOL does not support function pointers, so procedure pointers must be used instead.

D. (4) C/C++-to-C/C++ programs calls: This option is incorrect. Function pointers are typically used for C/C++-to-C/C++ program calls, not procedure pointers.

Therefore, the correct answer is:

The Answer is: C. (3) COBOL-to-COBOL programs calls

Multiple choice technology programming languages
  1. (1) Compute the arithmetic operations

  2. (2) Control the maximum number of digits allowed for decimal numbers

  3. (3) Control the inappropriate datatype if it is used by mistake

  4. (4) Identify the sign of the variable being used in the program

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The ARITH compiler option in IBM COBOL controls the maximum number of digits allowed for decimal numbers, determining whether the limit is 18 digits (COMPAT) or 31 digits (EXTEND).

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

The for loop syntax for(i=l; k< 5; j++){}; is valid in C-like languages. The initialization, condition, and increment can use different variables - this will compile even though the logic is unusual (i is initialized, k is checked, j is incremented). The semicolon after the empty body is also valid syntax.

Multiple choice technology testing
  1. The use of a variable before it has been defined.

  2. Unreachable (“dead”) code.

  3. Memory leaks.

  4. Array bound violations.

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

To answer this question, the user needs to have a basic understanding of static analysis and its limitations.

Static analysis is a technique for analyzing software without executing it. The technique involves examining the program's source code and/or binary code to identify potential errors, security vulnerabilities, and other issues.

Static analysis can help find many types of issues in software, but it also has limitations. Here are the explanations for each option:

A. The use of a variable before it has been defined: Static analysis can detect the use of a variable before it has been defined. This is because static analysis examines the code to identify potential issues before the code is executed.

B. Unreachable (“dead”) code: Static analysis can detect unreachable ("dead") code. This is because it examines the code to identify code paths that will never be executed.

C. Memory leaks: Static analysis can detect potential memory leaks in some cases, but it cannot detect all memory leaks. This is because some memory leaks are caused by runtime behavior that cannot be detected through static analysis.

D. Array bound violations: Static analysis can detect potential array bound violations, but it cannot always detect all violations. This is because some array bounds are determined at runtime and can only be detected through dynamic analysis.

Therefore, the correct answer is:

The Answer is: C. Memory leaks.

Multiple choice technology programming languages
  1. Yes

  2. No

  3. Compile error

  4. Don't know

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

Java allows implicit narrowing conversion from int literal to float when the value is within float's range. The integer 2 is automatically converted to 2.0f at compile-time, making this statement perfectly legal.

Multiple choice technology mainframe
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

DECLARE CURSOR is a declarative SQL statement that defines a cursor, not an executable statement. It declares the cursor's name and associated SELECT statement but doesn't actually execute the query. The cursor is activated when you OPEN it, not when declared.