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. program will abort

  2. command will fail but last line will remain populated in the file- variables

  3. command will fail and file-variables will be blank

  4. the program will give a compile time error

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

If the AT END clause is omitted during a sequential READ statement in COBOL, and no appropriate declarative error handler is defined, the compiler cannot determine the end-of-file behavior, leading directly to a compile-time error rather than runtime failures.

Multiple choice technology embedded technologies
  1. Use Macros

  2. Usage of Structures

  3. Combination of Both Structures and Unions

  4. Macros and Structures

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

In resource-constrained low-level programming, defining structures with bit-fields combined inside unions allows developers to overlay small bit-width fields onto larger datatypes, effectively reusing or freeing the remaining bits of the character for other union members to optimize RAM usage.

Multiple choice technology embedded technologies
  1. while(1) { LED(On) Delay(25) LED(Off) }

  2. main() { LED(On) Delay(25) LED(Off) while(1) { } }

  3. while(1) { LED(On) Delay(25) LED(off) Delay(25) )

  4. while(1) { Delay(25) LED(on) Delay(25) }

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

To blink an LED at equal intervals indefinitely, the code must loop continuously, toggle the LED state, and apply a delay after both turning it on and turning it off. Option 569320 correctly includes delays in both states within a while(1) loop, whereas others omit crucial delays or loops.

Multiple choice technology programming languages
  1. True

  2. False

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

Exceptions can be rethrown in catch blocks using the 'throw' keyword without arguments (preserving the original exception) or by throwing a new exception. Rethrowing allows handling at multiple levels - do some local handling then propagate up.

Multiple choice technology web technology
  1. the page will shut down.

  2. the page is defined as a target and will be found by the arrow command.

  3. window will open blank.

  4. when clicking a link, it will open in a new window.

Reveal answer Fill a bubble to check yourself
Multiple choice technology programming languages
  1. int[,] myarray;

  2. int[][] myarray;

  3. int myarray[,];

  4. int[2] myarray;

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

In C#, int[,] myarray; declares a rectangular 2-dimensional array where all rows have the same length. Option B int[][] is a jagged array (array of arrays), option C has wrong syntax, and option D declares a fixed-size 1D array.

Multiple choice technology programming languages
  1. new operator cannot be overloaded

  2. void *operator new(size_t,int);

  3. void operator new;

  4. void *operator new;

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

The correct syntax for overloading new for arrays is void operator new. This returns a pointer (void) and takes size_t parameter. The [] indicates array allocation. Option C is incorrect because it returns void instead of void*. Option B is the scalar new overload syntax (no []). The new operator CAN be overloaded, including for arrays.

Multiple choice technology programming languages
  1. try {throw 3;} catch(int i){ rethrow; }

  2. try {throw 3; rethrow ;} catch(int i){}

  3. try {throw 3;} catch(int i){ rethrow 3; }

  4. try {throw 3;} catch(int i){ throw; }

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

In C++, the correct syntax to re-throw the currently caught exception is a standalone throw; statement within a catch block. Specifying throw 3; or rethrow creates a new exception or results in syntax errors, as rethrow is not a keyword. Thus, the option using throw; is the syntactically correct choice.