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. True

  2. False

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

In C, malloc returns a void* pointer which is automatically converted to any other pointer type without explicit casting. Adding a cast is unnecessary and can actually hide errors if you forget to include stdlib.h. Modern C style recommends avoiding the cast. Option A is incorrect - casting is not required.

Multiple choice technology programming languages
  1. getchar();

  2. getche();

  3. ungetc();

  4. getch();

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

getche() and getch() are non-standard functions (common in Turbo C/C++ and Windows conio.h) that read characters with and without echo respectively. They are not part of the ANSI C standard library. getchar() and ungetc() are standard ANSI functions defined in stdio.h. Therefore options B and D are correct as the non-standard functions.

Multiple choice technology programming languages
  1. null pointer

  2. wild pointer

  3. Dangling pointer

  4. None of the above

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

Calling free() deallocates the memory block but does not modify the pointer itself. The pointer continues pointing to the deallocated memory, making it a dangling pointer. A null pointer must be explicitly assigned, and a wild pointer is one that is uninitialized.

Multiple choice technology programming languages
  1. Pointer to an array of 10 integers.

  2. A pointer to function returning an array of 10 integers.

  3. Array of 10 function pointers returning int

  4. Array of 10 integer pointers.

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

The declaration int (*a)[10] declares 'a' as a pointer to an array of 10 integers. The parentheses around (*a) are crucial - they make 'a' a pointer first, which then points to an array of 10 ints. Without parentheses, it would be an array of 10 pointers (int *a[10]). Option B incorrectly suggests a function pointer, option C describes int (*a[10])(), and option D describes int *a[10].

Multiple choice technology programming languages
  1. True

  2. False

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

In C, you cannot directly compare two structures using the == operator - it will cause a compilation error. Structures must be compared member by member, or using memcmp() for simple structures without padding. Option A (True) is incorrect because == doesn't work on structures. Note: This is a duplicate of question 155591.

Multiple choice technology testing
  1. General: Log

  2. General: Run Logic

  3. General: Miscellaneous

  4. General: Additional Attributes

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

The General: Log category in LoadRunner's run-time settings allows developers to configure logging behavior, including the option to send messages only when an error occurs. Meanwhile, Run Logic defines the execution flow, and Miscellaneous governs error handling and threads.

Multiple choice technology programming languages
  1. Functions

  2. Templates

  3. Function pointers

  4. Pointer of pointers

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

In C++, delegates are not built-in language constructs, but their conceptual equivalent is a function pointer (or std::function/functors), which stores a reference to a function to be called dynamically. Templates are compile-time code generators, and functions are direct invocations.

Multiple choice technology programming languages
  1. Pointers are not supported in C#

  2. Pointers are supported in C# as is in C++

  3. Pointers are replaced by delegates

  4. Pointers can be used by declaring unsafe blocks

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

C# does support pointers, but only within explicitly marked unsafe code blocks. This provides controlled access to pointer functionality while maintaining type safety by default, unlike C++ where pointers are freely available.

Multiple choice technology mainframe
  1. PARA A

  2. PARA B

  3. PARA C

  4. PARA D

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

The COBOL GOTO statement with DEPENDING ON uses 1-based indexing: GOTO A,B,C,D DEPENDING ON X transfers control to the first label when X=1, second label when X=2, third when X=3, fourth when X=4. When X=2, control transfers to PARA B. This is a computed GOTO based on the ordinal position of the labels.

Multiple choice technology business process management
  1. catch,finally

  2. finally

  3. catch

  4. catch,catch,finally

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

In Java, a try block must be followed by either a catch block, a finally block, or both. The options correctly identify valid combinations like try-catch-finally, try-finally, and multiple catches. However, the option "catch" is marked false when a single catch block is also syntactically valid in Java. Since 'catch' is marked false, the stored answers are partially inconsistent, but try-catch-finally and try-finally are indeed correct.