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. Buffer overflows are eliminated

  2. Variables are renamed to provide more meaningful context

  3. Exception handlers are added to catch runtime errors

  4. New features are added based on the latest iterative design changes

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

Refactoring is the process of restructuring existing computer code without changing its external behavior. Renaming variables to provide better readability and context is a classic refactoring activity.

Multiple choice technology programming languages
  1. Don't link your modules to modules written in any other language

  2. Make sure you declare all your variables' data types ahead of time

  3. Don't add variables of one type to variables of another

  4. Devout prayer

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

Assembly language does not have built-in type checking or type safety features. Since the hardware only sees raw bytes and registers, type safety cannot be enforced by the language itself, making 'devout prayer' a humorous but accurate choice.

Multiple choice technology operating systems
  1. True

  2. False

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

JavaScript is not related to Java. The similarity in names was a marketing decision by Netscape in 1995 when JavaScript was created. Java is a statically-typed, class-based language, while JavaScript is dynamically-typed and prototype-based. They are fundamentally different languages.

Multiple choice technology platforms and products
  1. -1

  2. 0

  3. 1

  4. NULL

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

For a REPEAT operation to continue indefinitely as long as a condition remains true, the count parameter should be set to -1. This indicates unlimited repetition. Setting count to 0 would typically mean no repetitions, 1 would execute once, and NULL might indicate an unset or default limited count.

Multiple choice technology enterprise content management
  1. lo w

  2. lo worl

  3. lo wo

  4. index out of range error during compilation

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

The substr(start, length) method extracts characters starting at index start for a specified length. For "Hello World", starting at index 3 ('l') for 7 characters yields "lo Worl" (case-sensitive 'W'). The stored option has a lowercase 'w', but it is the intended answer.

Multiple choice technology web technology
  1. The code will generate a run time error

  2. undefined, Local Date & Time.

  3. The code will generate a compile time error.

  4. Universal Date & Time, Local Date & Time.

  5. Local Date & Time & Local Date & Time

Reveal answer Fill a bubble to check yourself
D Correct answer
Multiple choice technology enterprise content management
  1. The code will generate a run time error.

  2. undefined, Local Date & Time.

  3. The code will generate a compile time error.

  4. Universal Date & Time, Local Date & Time.

  5. Local Date & Time, Local Date & Time

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

The toUTCString() method converts a Date object to a string using the UTC time zone (Universal Coordinated Time), while toString() returns the local date and time based on the system's time zone settings. This distinction is important when working with time-sensitive operations across different geographical regions.

Multiple choice technology programming languages
  1. p is a pointer to pointer to integer

  2. p is a pointer to a function that accepts an argument which is a pointer to a character and returns an integer quantity

  3. p is a function that accepts an argument which is a pointer to a character and returns an integer quantity

  4. p is a function that accepts an argument which is a pointer to a character and returns a pointer to an integer quantity

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

The syntax int p(char *a) declares a function named p that takes a pointer to a character (char *a) as its argument and returns an integer (int). It is not a pointer declaration.

Multiple choice technology mainframe
  1. Infinite loop

  2. Logical Error

  3. Runtime Error

  4. All of the above

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

COBOL IF statements can exhibit all three error types: infinite loops (when improperly nested in loops with incorrect exit logic), logical errors (incorrect condition logic leading to wrong execution path), and runtime errors (comparing incompatible data types or operating on invalid data).

Multiple choice technology programming languages
  1. p is a function that accepts an argument which is a pointer to a character and returns a pointer to a 10 element integer array

  2. p is a pointer to a function that accepts an argument which is a pointer to a character and returns an integer quantity

  3. p is a function that accepts an argument which is a pointer to a character and returns an integer quantity

  4. None of the above

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

The declaration int (p)(char *a) is read as: p is a pointer (declared with *p) to a function (the surrounding parentheses) that takes a char argument and returns an int. Option A incorrectly describes p as the function itself. Option C describes a function that returns int, not int*. The key is that the parentheses around *p force p to be interpreted as a pointer first, then binding to the function signature.

Multiple choice technology programming languages
  1. p is a function that accepts an argument which is a pointer to a character and returns an integer quantity

  2. p is a function that accepts an argument which is a pointer to a character and returns a pointer to an integer quantity

  3. p is a function that returns a pointer to an integer quantity

  4. None of the above

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

The declaration int p(void) declares p as a function that takes no arguments (void) and returns a pointer to an integer (int). Option A and B incorrectly claim the function accepts a char* argument, but void means no parameters. Option D is incorrect because option C is accurate.

Multiple choice technology programming languages
  1. p is a function that returns a pointer to an integer quantity

  2. p is a function that accepts an argument which is a pointer to a character and returns a pointer to an integer quantity

  3. p is a function that accepts an argument which is a pointer to a character and returns an integer quantity

  4. None of the above

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

In the declaration int *p(char *a), p is a function because of the function call parentheses (char *a). It takes a pointer to a character (char *a) as an argument and returns a pointer to an integer (int *).