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. 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 packaged enterprise solutions
  1. Switch case

  2. For

  3. If else

  4. Go to

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

The Branch operation in webMethods Developer evaluates conditional expressions and routes execution to different branches based on the result, which is directly analogous to if-else statements in C and other programming languages. Unlike switch-case (which matches a single value against multiple cases), Branch supports complex conditional expressions like if-else.

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

Multiple choice technology mainframe
  1. COND=(8,LE)

  2. COND=(8,GE)

  3. COND=(8,LT)

  4. COND=(8,GT)

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

The COND parameter tests if a condition is TRUE to SKIP the step. COND=(8,LE) means 'if return code is less than or equal to 8, skip this step'. So the step runs ONLY when return code is strictly less than 8 (NOT less than or equal to 8). This is the correct conditional logic for the stated requirement.

Multiple choice technology mainframe
  1. There is either a JCLLIB statement for the entire JOB, or a separate one for each EXEC statement, not both.

  2. A JCLLIB statement can not have a statement name.

  3. There can only be one JCLLIB statement per JOB.

  4. A JCLLIB statement must be coded before the first EXEC statement.

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

In JCL, the JCLLIB statement specifies the private libraries to be searched for cataloged or in-stream procedures. There can only be one JCLLIB statement per JOB, and it must appear before the first EXEC statement. Distractors claiming limits on EXEC interactions or names are incorrect.

Multiple choice technology programming languages
  1. Large number of Compound operators

  2. Function and data pointers supporting

  3. Small set of key words

  4. Automatic garbage collection

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

C does not have automatic garbage collection; developers must manage memory manually using malloc and free. Other features like compound operators, pointers (data and function), and a small keyword footprint are core characteristics of C.

Multiple choice technology programming languages
  1. *

  2. -

  3. +

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

To solve this question, the user needs to know about pointers in programming languages. A pointer is a variable that stores the memory address of another variable. The symbol used to declare a pointer variable is the asterisk symbol (*), thus option A is the correct answer.

Option A: * is the correct symbol to declare a pointer variable.

Option B: - is not used to declare a pointer variable.

Option C: + is not used to declare a pointer variable.

Option D: | is not used to declare a pointer variable.

The Answer is: A

Multiple choice technology programming languages
  1. lazy="true"

  2. lazy="false"

  3. lazy="on"

  4. lazy="off"

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

Batch fetching is a performance optimization used with lazy loading to avoid the n+1 select problem. When lazy="true", Hibernate can batch multiple lazy initialization requests into a single query. With lazy="false", data is eagerly loaded, making batch fetching unnecessary. Options C and D use invalid attribute values.