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. a. continue;

  2. b. break;

  3. c. return "Infant";

  4. d. return 0;

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

The function declares a string return type but has no return statement for ages 4 and below. Adding 'return "Infant";' as the last line ensures all execution paths return a string, satisfying the compiler's requirement that non-void functions must return a value on all paths.

Multiple choice technology programming languages
  1. a. true

  2. b. false

  3. c. an exception is thrown

  4. d. depends

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

Unboxing extracts a value type from an object reference. If that reference is null, there's nothing to extract, causing a runtime exception (NullReferenceException in C#). You cannot unbox null because unboxing requires an actual boxed value to retrieve.

Multiple choice technology programming languages
  1. a. Yes

  2. b. No

  3. c. Under certain conditions

  4. d. May be

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

Only ONE catch block executes for a given exception. Exception handlers are evaluated in order, and the first matching catch block handles the exception. Once executed, control jumps to the finally block (if any) and then continues after the try-catch structure. No other catch blocks run for that same exception.

Multiple choice technology programming languages
  1. a. readonly value can be changed later

  2. b. const items are dealt at compile time however readonly is dealt at runtime

  3. c. const value can be changed later

  4. d. const items are dealt at runtime however readonly is dealt at compile time

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

const is a compile-time constant - the value is embedded at compile time and cannot change. readonly is a runtime constant that can be assigned once (at declaration or in a constructor) and then becomes immutable. This is why const can only be used for value types and string literals, while readonly can reference any type.

Multiple choice technology
  1. memory

  2. register

  3. variable

  4. assembler

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

Operands are the data values that instructions operate on. Memory locations, registers, and variables can all serve as operands as they hold or reference data values. An assembler is a software tool that converts assembly language to machine code - it is not an operand but rather a program that processes instructions containing operands.

Multiple choice technology
  1. 1

  2. 2

  3. both

  4. none

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

Both syntax examples (1 and 2) are valid. In option 1, setProperty is nested inside the useBean body. In option 2, setProperty appears after the useBean tag closes. Both approaches work correctly - the nested approach is more compact while the separate approach is more flexible. Therefore option C 'both' is correct.

Multiple choice technology
  1. float ptr;

  2. float *ptr;

  3. *float ptr;

  4. None of the above

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

In C, a pointer to float is declared using an asterisk (*) before the variable name: float *ptr;. Option A (float ptr;) declares a regular float variable, not a pointer. Option C (*float ptr;) has incorrect syntax - the asterisk must come after the type, not before it.

Multiple choice technology programming languages
  1. exception

  2. harness

  3. assertion

  4. expression

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

An assertion is a statement that a programmer believes should always be true at a specific point in code execution. Assertions are used as debugging and testing aids to check assumptions during development, and typically trigger an error or exception if the condition evaluates to false.

Multiple choice technology platforms and products
  1. At least one variable must be added to a Global Variable group

  2. The predefined value of a Global Variable cannot be overridden from the command line

  3. The predefined value of a Global Variable for individual services can be changed at deployment time

  4. When using a Global Variable in the fields of a resource, enter the name surrounded by $
Reveal answer Fill a bubble to check yourself
A,C Correct answer
Explanation

A Global Variable group must contain at least one variable to be valid. Global Variable values can be overridden at deployment time for individual services. Global Variables can be overridden from the command line using the -var option, and they are referenced in resources using the syntax %%globalVariableName%%, not with $.

Multiple choice technology platforms and products
  1. Job Shared Variables can be modified at run-time, and Shared Variables cannot

  2. Shared Variables can be shared across process engines, and Job Shared Variables cannot

  3. Shared Variables can be shared across process instances, and Job Shared Variables cannot

  4. Job Shared Variables can be shared across process definitions in a project, and Shared Variables cannot

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

Shared Variables can be shared across multiple process engines in a distributed environment, while Job Shared Variables are confined to a single job instance. Shared Variables can also be shared across process instances within the same engine, but Job Shared Variables cannot be shared across different process instances. Both variable types can be modified at runtime, and Job Shared Variables are not scoped across process definitions.

Multiple choice technology architecture
  1. if

  2. then

  3. goto

  4. while

  5. case

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

In Java, 'then' is NOT a keyword or reserved word. Java's conditional statement uses 'if' and 'else' - 'then' is not part of the syntax. The other options ARE keywords or reserved words: 'if' is a conditional keyword, 'goto' is a reserved word (though not used), 'while' is a loop keyword, and 'case' is used in switch statements. This question tests knowledge of Java's reserved word list.