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
-
friend
-
virtual
-
inline
-
static
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.
B
Correct answer
Explanation
The 'java' command executes compiled Java bytecode using the JVM, while 'javac' is the compiler that converts source code to bytecode. This is a fundamental distinction in Java development.
-
Subsequent statements in the current processing blocks are executed
-
There is an error message
-
Program gets terminated
-
Subsequent statements in the current processing blocks are not executed
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.
-
Unmatched bracket in for statement
-
Flush attribute must be false
-
Keyword 'file' should be used instead of 'page' in the <jsp:forward/> action
-
Actions cannot be used within scriptlet blocks
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.
A
Correct answer
Explanation
Yes, an exception caught in a catch block can be rethrown to be handled by an outer try-catch block or propagated up the call stack using the throw keyword.
A
Correct answer
Explanation
Java allows method overloading, so you can have multiple main() methods with different parameter signatures. However, only public static void main(String[] args) serves as the JVM entry point.
-
xsl:if
-
xsl:do-while
-
xsl:while
-
xsl:ifelse
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.
-
TRUE
-
FALSE
-
CAN'T SAY
-
NONE OF THESE
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.
D
Correct answer
Explanation
In SQL*Plus, a single ampersand & prompts the user for a value every time it is encountered. The double ampersand && defines a substitution variable that prompts the user only once and reuses that value throughout the session without prompting again.
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.
-
<template>
-
<xsl:template>
-
<xsd:template>
-
<xml:template>
B
Correct answer
Explanation
XSLT uses XML namespaces to distinguish its elements. Templates are defined using the element, where 'xsl' is the namespace prefix bound to the XSLT namespace URI (http://www.w3.org/1999/XSL/Transform). The namespace prefix can vary, but the standard convention is 'xsl'.
-
FALSE
-
TRUE
-
NOT ALWAYS
-
NONE OF THESE
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.
-
the number of arguments
-
the number of arguments plus one
-
the number of arguments minus one
-
The total size of the argument array
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.
-
stdin.h
-
ctype.h
-
math.h
-
None
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.
-
int to float
-
float to int
-
char to float
-
All are possible
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.