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 performance
  1. If

  2. For

  3. Do

  4. While

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

The If keyword is a conditional statement that executes code based on whether a condition is true or false. For, Do, and While are loop constructs that repeat code blocks multiple times. Conditional statements control program flow based on conditions, while loops control iteration.

Multiple choice technology platforms and products
  1. If-then-else block

  2. Switch block

  3. While block

  4. Any of the above

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

Conditional branching in BPEL is implemented using the Switch activity, which evaluates multiple cases and executes the first one whose condition matches. This is similar to switch-case statements in programming languages. The if-then-else construct (option A) does not exist in standard BPEL, and while (option C) is used for looping, not conditional branching.

Multiple choice technology
  1. All fields in the record

  2. NULL

  3. {}

  4. By selecting unique field.

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

To count all records without grouping, Rollup uses an empty key specification denoted as {}. This tells Rollup to treat all records as one group and apply count() aggregation. Using all fields would group by every unique record combination. NULL is not valid syntax, and selecting a unique field would group by that field's values.

Multiple choice technology programming languages
  1. That's not legal syntax!

  2. foo has memory allocated for it, but is not constructed

  3. foo has memory allocated for it, and is fully constructed

  4. None of the above

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

In C++, operator new returns a void*, which cannot be implicitly converted to a typed pointer like myObj* without an explicit cast. Additionally, sizeof(foo) allocates space for the pointer size (4 or 8 bytes) rather than the object itself.

Multiple choice technology programming languages
  1. If realloc fails, then the original memory is lost

  2. Nothing, realloc is guaranteed to succeed (by returning the original pointer)

  3. Nothing, realloc frees the original memory passed to it

  4. None of the above

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

If realloc fails, it returns NULL and the original pointer to allocated memory is lost, causing a memory leak. The correct approach is to use a temporary pointer for realloc, check if it succeeded, then assign back. Realloc does not guarantee success, and option C is wrong because realloc does NOT automatically free the original memory on failure.

Multiple choice technology programming languages
  1. True

  2. False

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

The code uses the deprecated 'arguments' property of functions (tryVariableArguments.arguments) which was removed in modern JavaScript strict mode and is considered legacy. Even in non-strict mode, accessing arguments through the function object (functionName.arguments) is non-standard. The correct approach is using the implicit 'arguments' object within the function scope. Therefore, the code is not going to work fine in modern JavaScript environments.

Multiple choice technology programming languages
  1. True

  2. False

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

parseJSON is NOT a standard built-in JavaScript function like alert(), eval(), or parseInt(). Standard JSON parsing uses JSON.parse() (available in modern JavaScript) or eval() with careful validation in legacy code. There is no global parseJSON() function in standard JavaScript specifications.

Multiple choice technology
  1. NULL

  2. 0

  3. Results in a compilation error

  4. An Exception will be raised

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

In PL/SQL, variables declared without an initial value are automatically initialized to NULL. This is standard PL/SQL behavior and differs from some other languages where uninitialized variables might have indeterminate values or cause errors.

Multiple choice technology
  1. %rowtype, %toomanyrows, %found

  2. %found, %notfound, %rowcount

  3. %rowtype, %rowcount, %notfound

  4. None of the above

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

Implicit cursors are automatically created for SQL DML statements in PL/SQL. Their available attributes are %FOUND, %notfound, %ROWCOUNT, and %ISOPEN. %ROWTYPE is used for variable declarations matching a record structure, not cursor operations, and %TOOMANYROWS is not a standard attribute.

Multiple choice technology
  1. True

  2. False

  3. Undefined

  4. NULL

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

To solve this question, the user needs to understand the concept of NULL values and how they behave in comparison operations.

When two NULL values are compared to each other, the result is always NULL. This is because NULL represents an unknown value, so it is impossible to determine whether two unknown values are equal or not.

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

A. True: This option is incorrect because comparing two NULL values will always result in a NULL value, not a true value.

B. False: This option is incorrect because comparing two NULL values will always result in a NULL value, not a false value.

C. Undefined: This option is incorrect because NULL is a defined value in SQL, and the result of comparing two NULL values is also a defined value (NULL).

D. NULL: This option is correct. Comparing two NULL values will always result in a NULL value.

Therefore, the answer is: D. NULL