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. Char i = 9

  2. int i = 3/7

  3. String i = "abc"

  4. int i = 0

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

In Java, adding a string to another string (i + 0) performs string concatenation (e.g., "abc" + 0 yields "abc0"). Since "abc" is not equal to "abc0", i != i + 0 evaluates to true, and it loops indefinitely. For numeric types, adding 0 does not change the value, so the loop terminates immediately.

Multiple choice technology testing
  1. A. Built-in

  2. B. User-defined

  3. C. User-function

  4. D. Built-in, User-defined

  5. E. Built-in, User-function

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

Environment variables in shell/operating systems come in two main types: built-in variables provided by the system (like PATH, HOME, USER) and user-defined variables created by the user. Option D correctly identifies both types. Option C is incorrect because 'User-function' is not a type of environment variable.

Multiple choice technology testing
  1. A. For..Next, Select…..Case, Do…Loop

  2. B. If…EndIf, For…Next, While…Wend

  3. C. Do…loop, while…wend, select..case

  4. D. Do..while, While…End, For…next

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

QTP uses VBScript syntax for loops: Do...Loop (with Until/While), While...Wend, and For...Next. Option C lists Select..Case (a conditional, not a loop), and Options A/B mix incorrect combinations.

Multiple choice technology testing
  1. current date

  2. current system date

  3. future date

  4. previous date

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

The Date function in Visual Basic returns the current system date from your computer. It does not return past dates, future dates, or just the concept of 'current date' without system context - it specifically retrieves the date set in your system.

Multiple choice technology testing
  1. Current date and time

  2. current date

  3. current time

  4. current date and future date

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

The Now() function returns both the current date AND time as a single timestamp. Unlike Date() which returns only the date, Now() provides complete temporal information including hours, minutes, and seconds along with the calendar date.

Multiple choice technology web technology
  1. Single line c++ syntax - //

  2. Shell syntax - #

  3. Both of above

  4. None of above

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

PHP supports both C++ style single-line comments (//) and shell style comments (#). This flexibility allows developers to choose their preferred commenting style or use both in the same codebase for different purposes.

Multiple choice technology web technology
  1. echo()

  2. print()

  3. Printf()

  4. none

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

printf() is most suitable for blending static text with dynamic variables because it supports formatted strings with placeholders (%s, %d, etc.). This makes complex string construction more readable than concatenation with echo() or print().

Multiple choice technology web technology
  1. Declare cookie variables

  2. Store data in cookie variable

  3. Enable or disable cookie support

  4. All of the above

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

The setcookie() function in PHP sends a cookie to the browser, storing data in a cookie variable that will be sent back with subsequent requests. It does not declare variables (that's just variable assignment) nor does it enable/disable cookie support (that's controlled by browser settings).

Multiple choice technology web technology
  1. Faster

  2. Slower

  3. The execution speed is similar

  4. All of above

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

Scripts run slower than compiled programs because they are interpreted line-by-line at runtime, while compiled programs are already converted to machine code. The interpreter adds overhead for parsing and translating each instruction before execution.

Multiple choice technology web technology
  1. Local

  2. function parameter

  3. static

  4. None of above

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

Static variables retain their value between function calls because they are allocated in static memory and persist across function invocations. Local variables are destroyed when the function returns, and function parameters are reinitialized on each call.

Multiple choice technology web technology
  1. Local variables

  2. Function parameters

  3. Hidden variables

  4. Global variables

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

PHP supports local variables (function-scoped), global variables (accessible with global keyword or $GLOBALS), and function parameters. 'Hidden variables' is not a recognized scope type in PHP - the language only has local, global, static, and function parameter scopes.