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 packaged enterprise solutions
  1. True

  2. False

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

Function modules must be assigned to a function group in ABAP. Function groups provide the runtime environment and memory context for function modules. When a function module is called, its entire function group is loaded into memory. This allows function modules within the same group to share global data and memory, making the function group essential.

Multiple choice technology packaged enterprise solutions
  1. BAPIRET2

  2. BAPIRETURN

  3. BAPIRET

  4. All the Above

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

The standard associated type for the RETURN parameter in BAPIs is BAPIRET2. This structure contains fields like TYPE (S/E/W/A/I for message type), ID (message class), NUMBER (message number), MESSAGE, LOG_NO, LOG_MSG_NO, MESSAGE_V1 through MESSAGE_V4 (parameter values), and FIELD. BAPIRETURN is an older obsolete structure, and BAPIRET is not the standard. BAPIRET2 is the current, correct return structure.

Multiple choice technology platforms and products
  1. True

  2. False

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

C# 4.0 introduced named parameters, which allow specifying parameters by name along with their values. However, this doesn't mean parameters can be passed in arbitrary order - they must still follow the defined parameter order unless named parameters are explicitly used with the syntax methodName(parameterName: value).

Multiple choice technology platforms and products
  1. Optional parameters can make your code more readable and easier to maintain, and can reduce the amount of typing you have to do

  2. We can use optional parameters and no longer have to overload functions with a number of methods

  3. Optional parameters are created in C# by specifying a default value and must appear after required parameters

  4. Following is the way to specify optional parameters for function ReadFile static void ReadFile(string FileName:"", string OpenMode:"ReadOnly") {...}

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

Optional parameters in C# use the syntax parameterName = defaultValue, not parameterName: defaultValue. The colon syntax shown in option D is incorrect and would cause a compilation error. Options A, B, and C correctly describe the benefits and syntax rules for optional parameters.

Multiple choice technology programming languages
  1. infinite loop

  2. Error

  3. This will not go into the loop as TRUE is defined as 0.

  4. 0

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

The macro preprocessor replaces TRUE with the value 0. In C, any loop controlled by while(0) evaluates to false immediately. As a result, the program will bypass the loop body entirely rather than resulting in an compilation error or an infinite loop.

Multiple choice technology programming languages
  1. Public

  2. Private

  3. Protected

  4. Internal

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

In C++, access specifiers are public, private, and protected. Internal is not an access specifier in C++ - it's used in some other languages like C# to limit accessibility within the same assembly. The other options (public, private, protected) are all valid C++ access specifiers.

Multiple choice technology programming languages
  1. ‘self’ pointer

  2. std::auto_ptr pointer

  3. ‘Myself’ pointer

  4. ‘this’ pointer

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

To solve this question, the user needs to have knowledge of C++ programming language and the concept of member functions.

The implicit pointer that is passed as the first argument for nonstatic member functions in C++ is known as the 'this' pointer.

Option A: 'self' pointer is not a valid keyword in C++. Hence, this option is incorrect.

Option B: std::auto_ptr is a smart pointer that is used for automatic memory management in C++. However, it is not passed as the first argument for nonstatic member functions. Hence, this option is incorrect.

Option C: 'Myself' pointer is not a valid keyword in C++. Hence, this option is incorrect.

Option D: 'this' pointer is a pointer that points to the object for which the member function is called. It is passed as a hidden argument to non-static member functions. Hence, this option is correct.

Therefore, the answer is: D. 'this' pointer.

Multiple choice technology programming languages
  1. = (assignment operator)

  2. == (equality operator)

  3. –> (row operator)

  4. :: (scope resolution operator)

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

The scope resolution operator :: is one of the few operators in C++ that cannot be overloaded because it operates on names rather than object values. Conversely, the assignment (=), equality (==), and member access (->) operators are standard overloadable operators in C++.

Multiple choice technology programming languages
  1. Runtime Exception

  2. finally block will be executed

  3. finally block will not be executed

  4. Compilation error in else block

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

When System.exit(1) is called in the else block, the JVM terminates immediately. The finally block is NOT executed because System.exit() bypasses all normal termination logic. This is a key exception to the rule that finally blocks always execute - System.exit() is one of the rare cases where finally is skipped.

Multiple choice technology mainframe
  1. NOFLAGSAA

  2. NODEBUG

  3. NOEDF

  4. RENT

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

The NOEDF compiler parameter prevents CICS debugging transactions like CEDF (Execution Diagnostic Facility) from being used with the compiled COBOL program. NODEBUG is not a standard COBOL compiler option, and RENT is for reentrancy while NOFLAGSAA is unrelated to debugging.

Multiple choice technology databases
  1. 0

  2. NULL

  3. Depends on the scale and precision of the datatype.

  4. Without initialization, a variable cannot be used in the executable section of the block.

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

In PL/SQL, variables that are declared but not initialized default to NULL when execution begins. They do not default to 0, their default value does not depend on scale/precision, and they can still be used in the executable section.

Multiple choice technology databases
  1. If-Then-Else

  2. While loop

  3. GOTO

  4. DECODE

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

GOTO provides unconditional transfer of control to a labeled section within a PL/SQL block, allowing immediate jump to a specific part without any condition. If-Then-Else requires condition evaluation, While loops execute based on a condition, and DECODE is a function for value substitution, not a control structure.

Multiple choice technology databases
  1. Declaration

  2. Execution

  3. Exception

  4. Header

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

The Exception section (also called exception handler) is where user-defined and predefined exceptions are trapped and handled using WHEN clauses. The Declaration section declares variables and exceptions, the Execution section contains the main logic, and there is no 'Header' section in PL/SQL block structure.