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
In C and C++, sizeof is an operator (compile-time), not a keyword in the same category as if, while, etc. It's a built-in operator that evaluates to the size of a data type. The question's phrasing makes a technical distinction between keywords and operators.
-
File
-
Function
-
Class
-
Directory to deploy
A
Correct answer
Explanation
In VSTT's testing framework, the [DeploymentItem] attribute specifies a file to be deployed to the test deployment directory before test execution. This attribute takes a file path (not a directory, function, or class) as its parameter, ensuring required files are available when the test runs.
A
Correct answer
Explanation
JavaScript functions possess an implicit arguments array-like object that holds all arguments passed during a call. The script iterates over tryVariableArguments.arguments successfully for varying counts of parameters, making the code valid and functional.
B
Correct answer
Explanation
JavaScript distinguishes between variables and functions in terms of execution context and type. While they share the same scope namespace and can overwrite one another, they are hoisted differently, and the typeof operator uniquely distinguishes a 'function' from other types.
B
Correct answer
Explanation
parseJSON is not a standard JavaScript function. The standard way to parse JSON is using JSON.parse() method. Some older browsers had non-standard parseJSON implementations, but they were never part of the official specification.
-
Interger,String and Date
-
Interger,String and float
-
Interger,String and bool
-
Decimal,String and Date
A
Correct answer
Explanation
The ASP.NET RangeValidator control supports five data types for validation: String, Integer, Double, Date, and Currency. The selected option correctly lists Integer, String, and Date as supported types, while other options incorrectly include unsupported types like float or bool.
-
The switch & case statement
-
?:(ternary operator)
-
The nestedif statement
-
The #endif Statement
A
Correct answer
Explanation
The switch-case statement is specifically designed to replace multiple if-else statements when comparing a single value against multiple possible constants. It provides cleaner, more readable code for this scenario. The ternary operator (?:) is for simple conditional expressions, not multi-way branching. Nested if statements are what we're trying to avoid. #endif is a preprocessor directive for conditional compilation, not runtime logic.
-
continue;
-
break;
-
return "Infant";
-
return 0;
-
return;
C
Correct answer
Explanation
The question asks about fixing a compiler error by inserting a statement as the last line. While the full code context isn't visible, the correct answer is 'return "Infant";' which suggests the function expects a string return type. 'continue' and 'break' are used within loops, not as function exits. 'return 0' would be incorrect if the return type is string. 'return;' without a value is for void functions. The string return matches the likely function signature.
B
Correct answer
Explanation
In C#, the default underlying type of enum members is int, but the default value of the first enum member is 0, not 1. Unless explicitly assigned, enum constants start at 0 and increment by 1. For example: enum Color { Red, Green, Blue } means Red=0, Green=1, Blue=2. The statement incorrectly claims the default value is 1.
B
Correct answer
Explanation
In C#, only one catch block executes for a single try statement. When an exception occurs, the runtime searches for the first matching catch block and executes it - other catch blocks are skipped even if they would also match the exception type. To handle multiple exception types, you need either multiple catch blocks in sequence (only one executes) or catch a base exception type and check the specific type within.
-
Optional arguments
-
Named arguments
-
Positional Parameters
-
None of the above
B
Correct answer
Explanation
Named arguments allow you to specify arguments by parameter name rather than position. For example, instead of calling Method(1, 2), you can write Method(value1: 1, value2: 2), making the code more readable and allowing you to skip optional parameters. Optional arguments are parameters with default values, positional parameters are the traditional positional approach, and named arguments specifically refer to the name-association feature.
B
Correct answer
Explanation
Procedures in PL/SQL do NOT require IN/OUT parameters: they can have no parameters at all, only IN parameters, only OUT parameters, or any combination. The statement 'Procedure MUST have IN/OUT parameters' is therefore false. Procedures are flexible in their parameter declarations.
-
By setting the object to Null
-
By setting the object to Nothing
-
With Close keyword
-
None of the above
B
Correct answer
Explanation
In VB.NET, objects are dereferenced and released from memory by setting them to Nothing. This is different from C# and other languages that use null. The Nothing keyword assigns the object reference to null, allowing the garbage collector to reclaim memory.
-
OpenMode Enumeration
-
OpenAccess Enumeration
-
OpenShare Enumeration
-
None of the above
A
Correct answer
Explanation
OpenMode enumeration in VB.NET contains members like Append, Binary, Input, Output, and Random that specify how a file is opened. OpenAccess deals with read/write permissions, and OpenShare controls file sharing modes.
B
Correct answer
Explanation
The statement is false because 'final' and 'static' are NOT access specifiers - they are modifiers. Access specifiers in Java are public, private, protected, and default (package-private). Additionally, 'static' cannot be used for local variables, and 'final' has different semantics depending on context.