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
-
Jerome
-
Davin
-
error
-
firstname
A
Correct answer
Explanation
The code creates an object using the Object constructor, assigns firstname='Jerome' and lastname='Davin', then alerts personObj.firstname which outputs 'Jerome'. The alert() function displays the value of the firstname property.
-
purchase_date
-
Credit_card
-
null
-
credit_card & product_id
-
product_id
D
Correct answer
Explanation
In the association table Purchaser_Product, a composite primary key consisting of credit_card and product_id is required to uniquely identify the relationship between a purchaser and a product, as neither column is marked as a unique primary key individually.
-
Option Declare
-
Option Explicit
-
Option Mandate
-
None
B
Correct answer
Explanation
Using Option Explicit at the start of a VBScript file forces the developer to declare all variables before using them, preventing typos and bugs. Statements like Option Declare and Option Mandate do not exist in VBScript syntax, making them incorrect distractors.
A
Correct answer
Explanation
VBScript supports only a single data type called Variant, which can contain different types of information depending on how it is used. Because of this, you cannot declare a variable of a specific type like Integer or String. This makes the statement true, rendering the false option incorrect.
-
2
-
1
-
3
-
No index is required for referencing an element in a 2D array. Index is applicable only for 1D arrays.
A
Correct answer
Explanation
A 2-dimensional array requires exactly 2 indices to reference an element: one for the row and one for the column (e.g., array(1,2)). Option B is incorrect because one index only works for 1D arrays. Option C is incorrect as 2D arrays don't use 3 indices. Option D is incorrect because all arrays require indices for element access.
-
While … Wend
-
Do While … Loop
-
Do Until … Loop
-
VB Script doesn't have any deprecated loops at all.
B
Correct answer
Explanation
In VBScript (and QTP/UFT), Functions DO return values, while Subroutines do NOT. The statement claims the opposite, which is incorrect. Functions use the function name to return a value, while Subroutines are used for procedures that don't need to return a value.
-
The step does not execute.
-
The first numeric column is summed by default.
-
The GROUP BY clause is changed to an ORDER BY clause.
-
The step executes but does not group or sort data.
C
Correct answer
Explanation
In PROC SQL, if you use GROUP BY without any summary (aggregate) functions like SUM, COUNT, AVG, etc., SAS automatically converts the GROUP BY clause to an ORDER BY clause. The step still executes but performs sorting instead of grouping. The other options are incorrect.
-
Unreachable Code
-
Undeclared Variables
-
Faults in requirements
-
Too few comments
C
Correct answer
Explanation
Static analysis tools examine source code without running it, allowing them to detect structural issues like unreachable code, undeclared variables, or insufficient comments. However, they cannot evaluate whether the program meets business needs, meaning faults in requirements can only be identified through dynamic testing or manual reviews.
-
Conversion
-
Validation
-
Authorisation
-
Authentication
A
Correct answer
Explanation
Edit Input rules are primarily used for CONVERSION of data from one format to another. They transform input values before they are stored or processed, such as converting text to uppercase, formatting dates, or transforming numeric values. Validation is handled by Validate rules, Authorization by Authorization rules, and Authentication by Authentication rules.
-
A rule used to validate that the data entered in a field is an integer.
-
A rule used to ensure that all interested persons are apprised of a work object’s status
-
A rule used to ensure that all required fields are complete.
-
A rule used to validate that a user has the appropriate security to access a part of the application
C
Correct answer
Explanation
A Validation rule in Pega is primarily used to ensure that all required fields are complete and that data meets specified criteria. It does not validate data types (that's done by edit validates), check security permissions, or notify interested parties (that's done by routing).
-
show(byte b){ }
-
show(long l){ }
-
none of the above
-
compilation error
B
Correct answer
Explanation
The literal 10 is an int. Java method overloading selects the most specific applicable method. show(long) is invoked because int can be widened to long, but there is no show(int) or show(byte) that directly matches.
-
when arrays and references are passed
-
only when references are passed
-
args are not changed
-
Command line args are changed
A
Correct answer
Explanation
@, the default array for subroutine arguments, contains aliases to the actual passed elements. When arrays or references are passed, modifying @ changes the original data. For references, this affects the referenced object.
-
1 and 2
-
5 and 0
-
1 and 3
-
none of the above
B
Correct answer
Explanation
In Perl list assignment, scalars consume single elements while arrays consume remaining elements. Here, \$t gets 'India', @u consumes all remaining elements ('US', 'Japan', 'Spain', 'Mexico', 'China' - 5 elements), leaving nothing for \$v and @w. Therefore @u has 5 elements and @w has 0.
-
1 can only be called with predecleration of complex_num
-
1 and 2 are same
-
2 can only be called with predecleration of complex_num
-
1 is reference to a subroutine
C
Correct answer
Explanation
In Perl, calling a subroutine without the ampersand sigil requires a pre-declaration (or prior definition) to let the compiler parse it properly, whereas using the ampersand allows calling it without such declarations. Therefore, the second syntax relies on pre-declaration, making this option correct.