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
C
Correct answer
Explanation
The @_ array stores all parameters passed to a Perl subroutine. Each element can be accessed as $[0], $[1], etc. The other options are different special variables: $# is the last index of an array, $@ is the error message from eval, and @ alone is not a valid special variable.
D
Correct answer
Explanation
The redo statement restarts the current loop iteration without re-evaluating the loop condition. Unlike next (which skips to next iteration) or last (which exits the loop), redo repeats the same iteration from the beginning. 'repeat' and 'recall' are not Perl loop control keywords.
-
bless
-
createobject
-
create_object
-
blessed
A
Correct answer
Explanation
The bless function is Perl's object constructor mechanism - it associates a reference with a package/class, creating an object. Functions like createobject or create_object don't exist in Perl's OOP system. blessed is not a keyword (though exists() can check if something is blessed).
-
DESTROY
-
AUTOHANDLE
-
AUTOLOAD
-
AUTOLOADER
C
Correct answer
Explanation
AUTOLOAD is a special subroutine in Perl that gets called when an undefined subroutine is invoked. This enables dynamic method generation and graceful handling of missing methods. DESTROY (option A) is for object cleanup, and AUTOHANDLE/AUTOLOADER don't exist as special subroutines.
B
Correct answer
Explanation
BEGIN blocks execute at compile time in Perl, before most of the script is parsed. This makes them ideal for initialization tasks like loading modules. END blocks run at program termination, CHECK runs after compilation but before execution, and INIT runs at the start of execution.
-
warnings
-
strict
-
5.10.1
-
constant
-
strict
-
warning
-
switch
-
integer
C
Correct answer
Explanation
In program module terminology, 'switch' is a control flow statement, not a modular program unit. 'strict' and 'warning' are compiler directives or keywords in some languages, and 'integer' is a data type. However, the question's terminology is unclear across programming languages.
-
REWRITE
-
INSERT
-
DELETE
-
START
B
Correct answer
Explanation
In COBOL PROCEDURE DIVISION, REWRITE, DELETE, and START are standard verbs for file operations. INSERT is not a COBOL verb - it's an SQL statement used in database contexts, not in native COBOL file handling.
A
Correct answer
Explanation
For sequentially accessed relative files, REWRITE does not use the INVALID KEY phrase because REWRITE in sequential mode operates on the last record read and doesn't involve key lookup. WRITE, START, and READ can all trigger INVALID KEY conditions in sequential relative file processing when key-related issues occur.
A
Correct answer
Explanation
The RequestProcessor class (which handles processing) uses the Template Method pattern. It defines the skeleton of request processing in methods like processPreprocess(), processPopulate(), etc., with hooks for subclasses to override specific steps while maintaining the overall algorithm structure.
-
ASP.NET
-
JAVA
-
Visual C++
-
COBOL
B
Correct answer
Explanation
Hibernate is an Object-Relational Mapping (ORM) framework for Java applications. It maps Java objects to database tables and handles data persistence. Hibernate is not used in ASP.NET (.NET), Visual C++, or COBOL - those platforms have their own ORM solutions like Entity Framework, native C++ libraries, or COBOL-specific database interfaces.
B
Correct answer
Explanation
Java DOES support pass-by-reference in a limited sense - object references are passed by value. When you pass an object reference, you can modify the object's contents but cannot make the reference point to a different object. The claim that Java 'does not support pass by reference only pass by value' is therefore false - it's more nuanced.
A
Correct answer
Explanation
Java only supports variables defined within a class or method scope. Variables defined at the class level with static act similarly to global variables but are still scoped within their class, meaning Java does not have true global variables.
B
Correct answer
Explanation
In Java array syntax, int[] a, b[] declares 'a' as a 1D int array and 'b' as a 2D int array. However, int a[], b[] declares BOTH 'a' and 'b' as 1D int arrays. The brackets bind differently: in the first form, brackets apply only to the immediately preceding variable; in the second form, they apply to all variables in that declaration. This tests understanding of Java's mixed array declaration syntax.
-
false
-
true
-
none of the above
-
All of the above
B
Correct answer
Explanation
In JavaScript, null and undefined are loosely equal (== returns true) but strictly equal (=== returns false). This is because they represent different concepts but both represent 'empty' or 'absent' values.