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

Multiple choice technology programming languages
  1. <listener-class>

  2. <listener-type>

  3. <listener-name>

  4. <description>

Reveal answer Fill a bubble to check yourself
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.).

Multiple choice technology web technology
  1. <%! %>

  2. <%= %>

  3. <% %>

  4. None of the above

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

In JavaServer Pages (JSP), the &lt;%! ... %&gt; syntax is a JSP declaration, which is used to declare variables or methods that are compiled into the generated servlet class. &lt;%= ... %&gt; is an expression, and &lt;% ... %&gt; is a scriptlet.

Multiple choice technology programming languages
  1. Variables read with the SET statement will not be affected by it

  2. The RETAIN statement is used when a variable needs to be

  3. Variables will be initialized to the desired value in each iteration

  4. Variables are created during execution

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. It will be initialised to 1 in the begining

  2. It will have the observation number that caused the error

  3. It will not be dropped while writing into the dataset

  4. It can be used in expressions

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology programming languages
  1. 1 can only be called with predecleration of complex_num

  2. 1 and 2 are same

  3. 2 can only be called with predecleration of complex_num

  4. 1 is reference to a subroutine

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. Dim statement

  2. Option Explicit statement

  3. Con Statement

  4. Const Statement

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. Byval

  2. Byref

  3. ByArg

  4. ByRes

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. For next,Do loop, Switch Case

  2. For next, Do loop, While end

  3. If then, While end, Do loop

  4. For next, Switch case, If then

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology testing
  1. Built-in

  2. User-defined

  3. Built-in, User-defined

  4. User function

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

QTP environment variables come in two types: Built-in (predefined by QTP like TestName, ActionName, etc.) and User-defined (created by the user). Both types serve different purposes: built-in for system information and user-defined for test-specific data. Option C correctly identifies both available types.

Multiple choice technology programming languages
  1. No observations.No variables

  2. variable x is created with 3 observations with values 1,2 and 3

  3. Array should be given a name during initialization.Syntax Error

  4. The variables x1 , x2 and x3 are created with the values 1, 2 and 3

Reveal answer Fill a bubble to check yourself
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.

Multiple choice technology
  1. Special Function

  2. Test Function

  3. Scientific Function

  4. Encoding Function

Reveal answer Fill a bubble to check yourself
D Correct answer
Explanation

METAPHONE is an encoding function used for phonetic string matching. It improves upon the SOUNDEX algorithm by better handling English pronunciation patterns, making it useful for fuzzy name matching and duplicate detection. Unlike SOUNDEX, METAPHONE produces more accurate phonetic representations.

Multiple choice technology programming languages
  1. True

  2. False

Reveal answer Fill a bubble to check yourself
A Correct answer
Explanation

VALUE clauses should be avoided for dynamic variables because they are compile-time constants and cannot be changed at runtime. Dynamic variables need values assigned during program execution using MOVE or SET statements. Using VALUE clause on a dynamic variable creates a mismatch between compile-time and runtime behavior.