Computer Knowledge
Programming Fundamentals
2,611 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
A
Correct answer
Explanation
The RESET statement in Natural programming initializes variables to their default values or resets them to null. This is different from SET (assigns values), MOVE (transfers values), or ASSIGN (calculates and assigns). RESET is specifically for initialization and clearing variable states.
A
Correct answer
Explanation
In Informatica and most ETL tools, Date data types can only be converted to other Date formats or to String representations. Direct conversion to numeric types or other incompatible types requires intermediate string conversion. This is a standard datatype conversion rule.
-
<listener-class>
-
<listener-type>
-
<listener-name>
-
<description>
A
Correct answer
Explanation
When declaring a listener in web.xml, only is required - it specifies the fully qualified class name of the listener implementation. , , and are not valid or required sub-elements of . The listener class must implement the appropriate listener interface (ServletContextListener, HttpSessionListener, etc.).
-
<%! %>
-
<%= %>
-
<% %>
-
None of the above
A
Correct answer
Explanation
In JavaServer Pages (JSP), the <%! ... %> syntax is a JSP declaration, which is used to declare variables or methods that are compiled into the generated servlet class. <%= ... %> is an expression, and <% ... %> is a scriptlet.
-
Variables read with the SET statement will not be affected by it
-
The RETAIN statement is used when a variable needs to be
-
Variables will be initialized to the desired value in each iteration
-
Variables are created during execution
A
Correct answer
Explanation
In SAS, the RETAIN statement prevents variables from being reset to missing at the start of each DATA step iteration. However, it does NOT affect variables read with SET statement - those come from the input dataset and are not subject to RETAIN. The other options are incorrect - RETAIN initializes once (not each iteration), doesn't create variables during execution, and the statement is incomplete.
-
It will be initialised to 1 in the begining
-
It will have the observation number that caused the error
-
It will not be dropped while writing into the dataset
-
It can be used in expressions
D
Correct answer
Explanation
The ERROR automatic variable in SAS can be used in IF statements and other expressions within the DATA step. It's NOT initialized to 1 at the beginning (it's 0), doesn't hold the observation number, and CAN be dropped from output datasets depending on logic. Its main use is in conditional expressions.
-
when arrays and references are passed
-
only when references are passed
-
args are not changed
-
Command line args are changed
-
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
This refers to Perl subroutine predeclaration. In Perl, calling a subroutine before it's declared requires either predeclaration (forward declaration with 'sub name;') or using parentheses. Option 1 (likely '&sub or sub()) requires no predeclaration. Option 2 (likely just 'sub') requires predeclaration to avoid ambiguity with barewords. Thus option 2 specifically needs predeclaration of complex_num.
-
Dim statement
-
Option Explicit statement
-
Con Statement
-
Const Statement
D
Correct answer
Explanation
In VBScript (used in QTP/UFT and classic ASP), constants are declared using the Const statement, not Dim (which is for variables), Option Explicit (which forces variable declaration), or Con (which is not a valid statement). The Const statement creates a named value that cannot be changed during script execution, which is essential for maintaining code readability and preventing accidental modification of fixed values.
B
Correct answer
Explanation
In VBScript and QTP procedures, arguments are passed by reference (ByRef) by default. This means the procedure receives a reference to the original variable, so any changes made to the parameter within the procedure affect the original variable. ByVal must be explicitly specified if you want to pass a copy instead.
-
For next,Do loop, Switch Case
-
For next, Do loop, While end
-
If then, While end, Do loop
-
For next, Switch case, If then
B
Correct answer
Explanation
QTP uses VBScript, which provides For...Next, Do...Loop, and While...Wend (or Do While...Loop) as looping constructs. Option B correctly identifies these three. Option A incorrectly includes 'Switch Case' which is a conditional statement, not a loop. Option C mixes 'If then' which is conditional, not iterative.
-
Built-in
-
User-defined
-
Built-in, User-defined
-
User function
-
During flow execution as process conrtol advances from one task to another
-
At the end of activity step,after invoking the method, but before any transition step
-
Upon database commit when any object is saved to database
-
All of the above
D
Correct answer
Explanation
Declare rules execute at multiple points in PEGA processing. Some run during flow execution as control moves between tasks, others at activity step boundaries after method invocation but before transitions, and Declare Trigger rules specifically run when objects are committed to the database. The declare keyword provides automatic rule execution across these contexts.
-
No observations.No variables
-
variable x is created with 3 observations with values 1,2 and 3
-
Array should be given a name during initialization.Syntax Error
-
The variables x1 , x2 and x3 are created with the values 1, 2 and 3
D
Correct answer
Explanation
In SAS, defining an array x{3} with initial values (1,2,3) implicitly creates three variables named x1, x2, and x3 in the program data vector, assigning them the values 1, 2, and 3 respectively during execution of the DATA step.
-
put ALLVAR
-
put VAR
-
put ALL;
-
put ;
C
Correct answer
Explanation
In a SAS DATA step, the PUT _ALL_; statement is the correct syntax used to write the names and values of all variables in the program data vector (PDV) to the SAS log. The other options like _ALLVAR_ or _VAR_ are invalid SAS syntax.