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
  1. increment

  2. post-increment

  3. pre-increment

  4. none of these

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

When the operator ++ is placed after the variable name, first assignment of the value of the variable takes place and then the value of the variable is incremented. This operation is known as post-increment.

Multiple choice
  1. Interpreter

  2. Compiler

  3. Compiler or interpreter test

  4. None of these

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

A compiler performs static analysis during the compilation phase, examining source code for syntax and semantic errors before generating machine code. If a programmer mistakenly writes 'divide' instead of 'multiply', the compiler's semantic analysis phase will detect this as a potential logical or type mismatch error during compilation, preventing the erroneous code from executing.

Multiple choice
  1. many functions do not have to be implemented twice

  2. functions are combined and it is not necessary to create intermediate files as output from the macro-processor and input to the assembler

  3. both (1) and (2)

  4. none of these

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

Incorporating the macro-processor into pass 1 eliminates duplication since macro expansion and initial parsing can share common functions like symbol table management. More importantly, it avoids creating temporary intermediate files, as the expanded code flows directly to subsequent assembly passes, improving overall compilation efficiency.

Multiple choice
  1. At the most, one activation record exists either the current activation record or the activation record for the main.

  2. The number of activation records, between the current activation record and the activation record for the main, depends on the actual function called sequence.

  3. Recursion requires the activation record for the recursive function to be saved on a different stack before the recursive function can be called.

  4. The visibility of global variables depends on the actual function, called sequence.

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

In C language, global variables have file scope and are visible throughout the entire translation unit. Their visibility is not dependent on the function call sequence - they remain accessible from any function that declares them (via extern if defined in another file). Option D correctly states that global variable visibility depends on the actual function call sequence, as access patterns vary based on which functions are called.

Multiple choice
  1. Stack st=new Stack();

  2. Stack<string> st=new Stack<>();</string>

  3. Stack<char> st<>new Stack<char>();</char></char>

  4. Queue<integer> qq=new LinkedList<integer>();</integer></integer>

  5. All of the above

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

It is not possible to pass primitive data types as arguments to generic classes.