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

  2. virtual

  3. inline

  4. static

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

When a function is declared inline, the compiler attempts to replace the function call with the function's actual code at the calling location. This eliminates function call overhead. friend is for access, virtual for polymorphism, static for class-level sharing.

Multiple choice technology programming languages
  1. Subsequent statements in the current processing blocks are executed

  2. There is an error message

  3. Program gets terminated

  4. Subsequent statements in the current processing blocks are not executed

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

When a CHECK statement condition fails outside a loop structure, the current processing block terminates and subsequent statements in that block are not executed. This is standard control flow behavior - a failed check stops execution of the current code block.

Multiple choice technology web technology
  1. Unmatched bracket in for statement

  2. Flush attribute must be false

  3. Keyword 'file' should be used instead of 'page' in the <jsp:forward/> action

  4. Actions cannot be used within scriptlet blocks

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

JSP actions like are XML-based syntax that must be used outside of scriptlet blocks (<% ... %>). Within scriptlets, you should use programmatic equivalents like response.sendRedirect() or request.getRequestDispatcher().forward(). The syntax shown tries to mix XML action tags inside Java code blocks, which is invalid.

Multiple choice technology programming languages
  1. xsl:if

  2. xsl:do-while

  3. xsl:while

  4. xsl:ifelse

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

xsl:if is the XSLT instruction that enables conditional processing in stylesheets. It evaluates a test expression and processes its content only if the test condition is true. Unlike if-else in programming languages, xsl:if only has an if branch - for if-then-else logic, XSLT uses xsl:choose with xsl:when and xsl:otherwise elements. Options B and C are not valid XSLT elements. Option D is incorrect because the proper construct is xsl:choose/xsl:when/xsl:otherwise, not xsl:ifelse.

Multiple choice technology programming languages
  1. TRUE

  2. FALSE

  3. CAN'T SAY

  4. NONE OF THESE

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

The position() function in XPath and XSLT returns the context position - a number equal to the current node's position within the processed node sequence. For example, when processing a node-set with xsl:for-each, position() starts at 1 for the first node and increments for each subsequent node. This is commonly used for numbering items, creating alternating row styles, or processing specific nodes (like position() mod 2 = 0 for even-numbered items). The function always returns an integer representing the current context position.

Multiple choice technology databases
  1. &

  2. accept

  3. prompt

  4. &&

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

In SQL*Plus, a single ampersand &amp; prompts the user for a value every time it is encountered. The double ampersand &amp;&amp; defines a substitution variable that prompts the user only once and reuses that value throughout the session without prompting again.

Multiple choice technology testing
  1. True

  2. False

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

Function points are a software size measurement method based on the number and complexity of user-visible functions (inputs, outputs, inquiries, external interfaces, internal files). They do NOT measure lines of code - that would be LOC (Lines of Code) metrics. The two are different measurement approaches.

Multiple choice technology programming languages
  1. FALSE

  2. TRUE

  3. NOT ALWAYS

  4. NONE OF THESE

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

In database systems and object-oriented programming, attributes or fields can be assigned default values that are automatically used when no explicit value is provided during record creation or object instantiation. This is a fundamental feature that ensures data integrity and prevents null values.

Multiple choice technology programming languages
  1. the number of arguments

  2. the number of arguments plus one

  3. the number of arguments minus one

  4. The total size of the argument array

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

The argument count (argc) includes the program name as argv[0], so it's always one more than the number of command-line arguments passed. If you run ./prog arg1 arg2, argc is 3 (program name + 2 arguments). This is why argc equals number of arguments plus one, not just the argument count.

Multiple choice technology programming languages
  1. stdin.h

  2. ctype.h

  3. math.h

  4. None

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

Typecasting is a fundamental language feature in C++, not a library function. No header file is needed to use C-style casts (int)x or C++ casts static_cast(x). Options A, B, and C are all real headers but for different purposes (stdio, character types, math functions). Typecasting syntax is built into the compiler.

Multiple choice technology programming languages
  1. int to float

  2. float to int

  3. char to float

  4. All are possible

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

All listed conversions are possible in C++ between primitive types. int to float is widening (always safe). float to int truncates the fractional part. char to float converts ASCII numeric value to floating point. These are all standard type conversions available through implicit or explicit casting.