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 databases
  1. TRUE

  2. FALSE

  3. Undefined

  4. NULL

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

In SQL, NULL represents an unknown value. When two NULL values are compared using operators like =, <>, >, <, etc., the result is NULL (unknown), not TRUE or FALSE. This is because NULL is not a value but a marker for missing information, so comparing two unknowns yields an unknown result.

Multiple choice technology programming languages
  1. True

  2. False

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

The statement is false. Java's arithmetic type promotion rules are more nuanced than simply taking the 'widest' type. For binary operations, Java uses 'widening primitive conversion' which promotes smaller types to int or long specifically, not just to the widest operand. For example, byte + byte produces int, not byte. char + byte produces int. Only if both operands are at least int does the result type become the wider of the two. The rule is: if either operand is double, result is double; else if float, result is float; else if long, result is long; otherwise, result is int.

Multiple choice technology
  1. -1

  2. 0

  3. 1

  4. -1/1

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

For a REPEAT operation in webMethods FLOW to execute continuously as long as the condition remains true (indefinite loop), the count parameter must be set to -1. A count of 0 means no iterations, while 1 means exactly one iteration. The option '-1/1' is not a valid count value.

Multiple choice technology programming languages
  1. Heap

  2. Stack

  3. Code Segment

  4. Data Segment

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

Static variables in C are stored in the data segment (specifically, the .data or .bss section depending on initialization). Unlike local variables which are on the stack, static variables retain their value across function calls and are allocated when the program starts, persisting for the entire program duration. Heap is for dynamic allocation (malloc/free) and code segment stores executable instructions.

Multiple choice technology programming languages
  1. Heap

  2. Stack

  3. Code Segment

  4. Data Segment

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

The variable test1 is a local non-static variable declared inside the func() function, so it is allocated on the stack. Local variables (automatic storage duration) are created on the stack when the function is called and destroyed when the function returns. Heap is for dynamic allocation (malloc), code segment for instructions, and data segment for static/global variables.

Multiple choice technology
  1. Byte Code

  2. Firewall

  3. Tetra Code

  4. View Code

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

Bytecode is a highly optimized set of instructions designed to be executed by the Java runtime system (JVM). When Java source code is compiled, it produces bytecode which is a compact, platform-independent representation that the JVM interprets or compiles further into native machine code.

Multiple choice technology programming languages
  1. True

  2. False

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

The code compiles successfully because k is initialized to 0 by default. The loop condition k<10 is true initially, so the loop body runs. After that, k remains 0 while i increments, so this becomes an infinite loop (until integer overflow). The issue is a logical error, not a compilation error.

Multiple choice technology programming languages
  1. a) getenv(), setenv()

  2. b) getenv(), putenv()

  3. c) readenv(), writeenv()

  4. d) You cannot environmement variables inside a program

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

getenv() retrieves environment variable values, while putenv() sets or modifies them. These are standard C library functions for environment variable manipulation. Options A uses setenv() which also exists but the question asks for the standard pair.

Multiple choice technology programming languages
  1. a) lazy="true"

  2. b) lazy="false"

  3. c) lazy="on"

  4. d) lazy="off"

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

Batch fetching in Hibernate is specifically useful when lazy loading is enabled (lazy="true"). It allows Hibernate to load multiple lazy associations in batches rather than one at a time, reducing the number of database queries and improving performance.

Multiple choice technology programming languages
  1. a) lazy="true"

  2. b) lazy="false"

  3. c) lazy="on"

  4. d) lazy="off"

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

Batch fetching in Hibernate is specifically useful when lazy loading is enabled (lazy="true"). It allows Hibernate to load multiple lazy associations in batches rather than one at a time, reducing the number of database queries and improving performance.

Multiple choice technology programming languages
  1. a) Yes

  2. b) No

  3. c)

  4. d)

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

The system() function in C/C++ executes a shell command and returns an implementation-defined value that can be processed. Typically, it returns the exit status of the command (or 0 on success, -1 if fork fails, or another value if the shell could not be executed). Programmers routinely check this return value to determine if the command succeeded or failed, making it processable.