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
-
Quicksort
-
Linear Search
-
Bubble Sort
-
none of the above
B
Correct answer
Explanation
For 200,000 elements: Quicksort is O(n log n) ≈ 3.6M operations, Linear Search is O(n) = 200K operations, and Bubble Sort is O(n²) = 40B operations. Linear search is fastest, so you'd wait the least time for it.
A
Correct answer
Explanation
In IDEAL, the default scrolling method can be changed to cursor-based scrolling. This allows users to use cursor keys for navigation instead of the default scrolling behavior. This is a configuration option within the IDEAL environment to customize user interaction with the screen.
B
Correct answer
Explanation
Fields and properties cannot share the same name in the same scope. They would conflict - the property would typically wrap the field with a different name (e.g., private field _name, public property Name).
A
Correct answer
Explanation
Properties are language constructs that work at compile time for type checking and code generation, and at runtime for executing getter/setter logic. Both phases are involved in property behavior.
-
Thread.Sleep(-1)
-
Thread.Sleep(0)
-
Thread.Interupt()
-
Thread.Wait()
A
Correct answer
Explanation
In .NET, passing -1 to Thread.Sleep makes the thread sleep indefinitely until it is interrupted or aborted. Other values like zero yield the processor briefly.
B
Correct answer
Explanation
In C and C++, main() returns int by default. The return value indicates the program's exit status (0 for success, non-zero for error). While some compilers allow void, the standard specifies int as the return type.
C
Correct answer
Explanation
string is a class in C++ (std::string), NOT a basic data type. The basic types are int, char, float, double, bool, and wchar_t. string is part of the Standard Library and provides string manipulation functionality.
-
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.
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.
-
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.
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.
A
Correct answer
Explanation
A pointer variable stores a memory address. When you declare int* a, the variable a itself holds an address. Accessing a returns that address value. Dereferencing (*a) gives the value at that address. Taking address of a (&a) gives the address where the pointer variable is stored, not the address it holds.