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
B
Correct answer
Explanation
DECLARE CURSOR is a declarative statement, not an executable SQL statement. It defines the cursor's characteristics (the query and attributes) but does not actually process any data. The OPEN statement executes the cursor declaration by processing the query, and FETCH retrieves the actual rows.
B
Correct answer
Explanation
Unlike C and C++, sizeof is not a keyword in Java because Java does not need to determine the size of data types at compile-time due to its platform-independent virtual machine.
B
Correct answer
Explanation
Garbage collection reclaims memory from unused objects, but it doesn't prevent out-of-memory errors. If you create objects faster than GC can collect them, or if you have memory leaks (unintentional object references), the program can still exhaust available heap space. GC is a management tool, not a memory guarantee.
B
Correct answer
Explanation
In Java, null is a literal (specifically, the null literal) rather than a keyword, although it cannot be used as an identifier.
-
int[,] myArray;
-
int[][] myArray;
-
int[2] myArray;
-
System.Array[2] myArray;
A
Correct answer
Explanation
The comma syntax int[,] declares a rectangular two-dimensional array in C#. int[][] is a jagged array (array of arrays), int[2] is invalid syntax, and System.Array[2] is not valid array declaration syntax.
-
With OPTION STRICT ON keyword
-
With OPTION EXPICIT Keyword
-
With OPTION STRICT OFF keyword
-
All the above
A
Correct answer
Explanation
To enable Strict Type Checking in VB.NET, you need to use the "Option Strict On" keyword. This will enforce data type checking for all variables, parameters, and return types in your code.
Option Explicit, on the other hand, enforces explicit declaration of all variables in your code.
Option Strict Off disables strict type checking and allows automatic type conversions, making it easier to write code but potentially less safe.
Therefore, the correct answer is:
The Answer is: A. With OPTION STRICT ON keyword
-
Exit
-
Close Sub
-
Exit Sub
-
Kill
C
Correct answer
Explanation
Exit Sub immediately terminates execution of a VB.NET Sub procedure. Exit alone is incomplete, Close Sub is not valid syntax, and Kill is not a language keyword (it relates to file operations in some contexts).
-
Exit
-
Close Sub
-
Exit Sub
-
Kill
C
Correct answer
Explanation
In VB.NET, you terminate the execution of a subroutine (method) immediately and return control to the calling code using the Exit Sub statement.
-
RRW object
-
RAW object
-
RCW object
-
None of the Above
C
Correct answer
Explanation
In .NET, a Runtime Callable Wrapper (RCW) acts as a proxy that manages the lifetime and interaction between a .NET reference type variable and a COM object.
-
Option Explicit
-
Option Strict
-
Option All
-
All of the Above
B
Correct answer
Explanation
In VB.NET, turning on Option Strict restricts implicit data type conversions to only widening conversions, thereby disallowing incompatible or narrowing type conversions that could result in data loss.
-
the use of a variable before it has been defined
-
unreachable code
-
memory leaks
-
array bound violations
C
Correct answer
Explanation
Memory leaks are a runtime phenomenon that depends on dynamic allocation and deallocation patterns during program execution. Static analysis can detect potential leaks through code inspection but cannot definitively identify actual memory leaks without runtime information. The other options are all detectable through compile-time analysis.
B,C
Correct answer
Explanation
In C, int and long are fundamental built-in data types. C does not have a boolean type by name (C99 added _Bool but it's not called 'boolean'), and String is not a datatype - strings are implemented as null-terminated char arrays or char pointers.
A
Correct answer
Explanation
The .NET Garbage Collector is designed to run automatically when memory thresholds are exceeded, when the system experiences high memory pressure, or when an explicit collection is requested.
-
Serialization
-
Garbage Collection
-
Assemblies
-
Overriding
B
Correct answer
Explanation
The .NET Framework provides automatic memory management through Garbage Collection. The Garbage Collector automatically allocates and manages memory for applications, reclaiming memory from objects that are no longer in use. Serialization converts objects to streams, Assemblies are deployment units, and Overriding is an object-oriented programming concept.
B
Correct answer
Explanation
Float.isNan(x) is the correct way to check for NaN (option a has typo). Using x == Float.NaN always returns false because NaN is defined as not equal to any value including itself. Option c's correctness depends on Myobject's equals implementation, but Float's equals method correctly handles NaN.