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

Multiple choice technology programming languages
  1. It's the same as a constant

  2. It's value can be assigned only once

  3. You can never assign a value to it

  4. You can assign value multiple times

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

A readonly field in C# can only be assigned a value during its declaration or within the class's constructor. Once the constructor finishes, its value becomes immutable. This differs from constants, which must be known at compile-time, and regular variables, which can be reassigned multiple times.

Multiple choice technology programming languages
  1. DLLImport

  2. UsingDLL

  3. DLLCall

  4. CallDLL

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

DllImport is the attribute used in C# to call methods from unmanaged code, including COM objects and native DLLs. The syntax is [DllImport("dllname.dll")] for external method declarations. The other options (UsingDLL, DLLCall, CallDLL) are not valid C# keywords or attributes.

Multiple choice technology programming languages
  1. delegate {TheMethod( int Z) }

  2. delegate void TheMethod(int Z) ;

  3. delegate: TheMethod (int Z)

  4. delegate: {TheMethod (int Z)}

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

The correct delegate declaration syntax in C# is 'delegate returnType MethodName(parameters)'. Option B shows this correctly: 'delegate void TheMethod(int Z)'. The other options use incorrect syntax with braces, colons, or missing return types.

Multiple choice technology programming languages
  1. char * (f* (*) ))

  2. char * ( f) (()());

  3. (char) (f) (());

  4. (char) (*f) ()();

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

This declares a function pointer 'f' that returns a char pointer and takes one argument - a pointer to a function taking no arguments and returning nothing. The syntax is 'char (*f)(void ()(void))' or equivalent with spacing. Option B's parenthetical structure, despite spacing oddities, best represents this complex declaration.

Multiple choice technology mainframe
  1. The above exec will prompt the user for a code until the user enters the code ‘BYE’

  2. The above exec will prompt the user for a code until the user enters the code ‘EXIT’.

  3. Gives Error while Executing

  4. The above exec will prompt the user for a code until the user enters the code ‘END’.

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

The REXX script uses a Do forever loop to repeatedly prompt the user and read input using Pull code. The Pull instruction converts input to uppercase. If the input matches 'BYE', the Leave statement terminates the loop, and the program exits. Other options specify incorrect termination conditions.

Multiple choice technology programming languages
  1. Type N

  2. Type C

  3. Type F

  4. Type P

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

In SAP ABAP, the PARAMETERS statement can only use data types N (numeric text), C (character), and P (packed decimal). Type F (floating-point) is not allowed for PARAMETERS because it can cause precision issues and is not suitable for user input parameters. Floating-point types are better suited for internal calculations.

Multiple choice technology mainframe
  1. deletes buffer in the stack

  2. deletes buffer and all elements of stack

  3. deletes elements of stack

  4. All the above

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

In SAP, the DROPBUF 0 command deletes the buffer and ALL elements of the stack. The argument '0' specifies deleting all buffers and stack contents. Option A is incomplete (only buffer), Option C is incomplete (only stack elements), so Option B correctly describes the complete action.

Multiple choice technology programming languages
  1. DO WHILE

  2. METHOD

  3. IF

  4. FOR

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

The COBOL PERFORM statement, especially when used with the UNTIL phrase, functions as a conditional loop. This is equivalent to DO WHILE or while loops in Java or C++. IF is a conditional branch, METHOD is a function definition, and FOR is a different loop structure.

Multiple choice technology operating systems
  1. Used to initialize some value to a variable

  2. Numeric values are set to zero, alphabetic and alphanumberic variables are set to spaces.

  3. All variables are set to spaces.

  4. None of the above

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

The INITIALIZE verb sets numeric data to zeros and alphanumeric/alphabetic data to spaces. It's a convenient way to reset data items to their default empty values without setting each one individually.

Multiple choice technology mainframe
  1. Will contain zeroes if numeric and spaces if alphabetic or alphanumeric

  2. Will contain spaces for all variables

  3. Will contain an undefined value

  4. None of the above

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

In COBOL, uninitialized variables contain whatever garbage data happens to be in their allocated memory location, making their initial value undefined. They do not automatically default to spaces or zeroes unless explicitly initialized using the VALUE clause or the INITIALIZE statement.

Multiple choice technology programming languages
  1. Buffers are always used

  2. Choice of buffer can be made to use

  3. Buffers are always bypassed

  4. None of above

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

In inner and outer joins, buffers are always bypassed because the database must access the actual table data to perform the join operation correctly across tables. Using buffered data could produce inconsistent results since buffers only contain individual table data.