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 web technology
  1. isNumber()

  2. isString()

  3. typeof()

  4. Option 1 & 2

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

The typeof operator in JavaScript returns a string indicating the type of the operand's value. It can return 'number', 'string', 'boolean', 'undefined', 'object', or 'function'. Functions like isNumber() and isString() are not built-in JavaScript functions.

Multiple choice technology web technology
  1. 0

  2. undefined

  3. Exception(0365): object undefined!

  4. Javascript error in the browser

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

JavaScript is case-sensitive, so 'sum' and 'Sum' are two completely different variables. The code only assigns a value to 'sum', leaving 'Sum' uninitialized. When alert(Sum) is called, it outputs 'undefined' because the variable Sum was never assigned a value.

Multiple choice technology web technology
  1. Mode value is 1Mode value is 2Mode value is 3

  2. Mode value is 1

  3. JavaScript error in the browser

  4. None of the above

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

This switch statement lacks break statements, so it exhibits fall-through behavior. Once mode matches case 1, execution continues through case 2 and case 3, printing all three messages. Without break statements, every case after the matching one executes.

Multiple choice technology web technology
  1. 1

  2. 11

  3. undefined

  4. null

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

JavaScript arrays are dynamic and their length is determined by the highest index plus one. When you assign a value to index 10, the array automatically expands to have a length of 11 (indices 0-10), even though only one element has an actual value.

Multiple choice technology web technology
  1. -1

  2. 4

  3. JavaScript error in the browser

  4. 5

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

The indexOf method returns the position of the first occurrence of a substring. In 'JavaScript is the best', counting starts from 0, so 'J' is at position 0 and 'S' is at position 4. The substring 'Script' starts at index 4.

Multiple choice technology web technology
  1. drizzling, but now it is heavily raining

  2. The day started drizzling, but now it is heavily raining

  3. drizzling

  4. null

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

The regex pattern /(dr.*ing)/ matches text starting with 'dr' and ending with 'ing', capturing everything in between. In the sentence, 'drizzling, but now it is heavily raining' matches this pattern (dr + izzling, but now it is heavily rain + ing). The match is stored in RegExp.$1.

Multiple choice technology programming languages
  1. No Value Returned

  2. -1

  3. 1

  4. 0

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

C++ programs conventionally return 0 to the operating system to indicate successful execution, following a universal programming standard. Non-zero return values typically signal errors or specific exit conditions. This convention allows scripts and other programs to programmatically detect whether a program completed successfully.

Multiple choice technology programming languages
  1. Inline functions

  2. virtual functions

  3. Both A and B

  4. None of the above

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

Inline functions eliminate function call overhead by inserting the function's code directly at each call point during compilation, rather than using a standard function call mechanism. This optimization is particularly useful for small, frequently-called functions. Virtual functions enable polymorphism through dynamic dispatch and are not inlined by default.

Multiple choice technology programming languages
  1. conditional statement

  2. assignment statement

  3. looping statement

  4. None of the Above

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

Assignment statements using the = operator assign values to variables in C++. Conditional statements (if/else) control flow, and looping statements (for/while) repeat code blocks - none directly assign values.