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

Multiple choice technology programming languages
  1. (a) CALL . . . BY CONTENT literal

  2. (b) CALL . . . BY CONTENT identifier

  3. (c) CALL . . . BY CONTENT ADDRESS OF identifier

  4. (d) CALL . . . BY CONTENT ADDRESS OF identifier

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

To solve this question, the user needs to know the different ways to pass parameters to a subprogram in programming languages.

The options in the question are using the "CALL" statement to pass a copy of the identifier to a subprogram. The CALL statement is used to transfer control to a subprogram (procedure or function) and pass arguments, if any.

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

A. (a) CALL . . . BY CONTENT literal: This option is incorrect because it passes a literal value to the subprogram, not an identifier. The "BY CONTENT" phrase specifies that the value is passed by value, which means a copy of the value is passed to the subprogram.

B. (b) CALL . . . BY CONTENT identifier: This option is correct because it passes a copy of the identifier (variable name) to the subprogram. The "BY CONTENT" phrase specifies that the value of the identifier is passed by value, which means a copy of the value is passed to the subprogram.

C. (c) CALL . . . BY CONTENT ADDRESS OF identifier: This option is incorrect because it passes the address of the identifier to the subprogram, not a copy of the value. The "BY CONTENT ADDRESS OF" phrase specifies that the address of the identifier is passed by value, which means a copy of the address is passed to the subprogram.

D. (d) CALL . . . BY CONTENT ADDRESS OF identifier: This option is incorrect because it is the same as option C, which passes the address of the identifier to the subprogram.

Therefore, the correct answer is:

The Answer is: B. (b) CALL . . . BY CONTENT identifier

Multiple choice technology programming languages
  1. (a) CALL . . . RETURNING

  2. (b) CALL . . . RECURRING

  3. (c) CALL . . . RECURSIVE

  4. (d) CALL . . . REFERRING

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

In COBOL, when calling a subprogram that returns a value, the correct syntax is 'CALL identifier USING ... RETURNING identifier'. The RETURNING clause captures the function's return value. Options B, C, and D use incorrect keywords (RECURRING, RECURSIVE, REFERRING) that are not valid in this context.

Multiple choice technology programming languages
  1. True

  2. False

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

To solve this question, the user needs to understand what the LANGUAGE compiler option and the NATLANG runtime option do.

The LANGUAGE compiler option specifies the programming language used in the code, while the NATLANG runtime option specifies the natural language used in the input and output of the program.

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

A. True: This option is correct. The LANGUAGE compiler option and the NATLANG runtime option are independent of each other. The compiler only needs to know the language being used to compile the code, while the NATLANG runtime option is used to determine the natural language used in input and output. These two options do not interact with each other and can be used independently.

B. False: This option is incorrect. The LANGUAGE compiler option and the NATLANG runtime option can be used independently of each other. They serve different purposes and do not depend on each other.

The Answer is: A

Multiple choice technology programming languages
  1. True

  2. False

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

In COBOL, record areas defined in the FILE SECTION of the DATA DIVISION are accessible to the main program regardless of whether it contains explicit I/O statements. These record areas are part of the program's data storage and can be manipulated like any other data area. The statement is true - I/O statements are for accessing external files, not for accessing internal record areas.

Multiple choice technology programming languages
  1. (1) USING PICTURE Clause

  2. (2) The USAGE IS FUNCTION-POINTER clause

  3. (3) The USAGE IS PROCEDURE-POINTER clause

  4. (4) The USAGE IS FUNCTION-ADDRESS clause

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

To answer this question, the user needs to have knowledge about procedure pointers in COBOL.

Option A is incorrect because the USING PICTURE clause is used to define the picture of data items.

Option B is incorrect because the USAGE IS FUNCTION-POINTER clause is used to define function pointers, not procedure pointers.

Option C is the correct answer. The USAGE IS PROCEDURE-POINTER clause is used to define procedure pointers in COBOL. Procedure pointers are data items that store the addresses of procedures.

Option D is incorrect because the USAGE IS FUNCTION-ADDRESS clause is used to define a data item that stores the address of a function, not a procedure.

Therefore, the answer is:

The Answer is: C. (3) The USAGE IS PROCEDURE-POINTER clause.

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.

Multiple choice technology programming languages
  1. Store the processing position in a FOR loop.

  2. Store the processing position in a IF loop.

  3. Store the processing information in a FOR loop.

  4. )Remembers your User ID

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

The REMEMBER statement in Model 204 stores the current processing position within a FOR loop, allowing you to return to that point later. This is useful for resuming iteration from a saved position rather than starting over.

Multiple choice technology programming languages
  1. True

  2. False

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

In Model 204, the ADD statement for adding new field values to records is indeed restricted to use within a FOR EACH RECORD loop. This is because ADD operates on the current record context, which is only established inside the loop. Outside the loop, there is no current record to which fields can be added.