Computer Knowledge

Programming Fundamentals

2,381 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. 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) By using the mutable="false" attribute in the class mapping.

  2. b) By using the ismutable="false" attribute in the class mapping.

  3. c) By using the ismutable="no" attribute in the class mapping.

  4. d) None

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

In Hibernate ORM mapping, the mutable="false" attribute tells Hibernate that the entity's state never changes after initialization. This allows Hibernate to optimize performance by skipping dirty checking during flush operations for this entity. The ismutable attribute name doesn't exist in Hibernate.

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.

Multiple choice technology databases
  1. NULLIF

  2. LENGTH

  3. CONCAT

  4. INSTR

  5. TAN

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

CONCAT can return non-null when passed NULL arguments. In most SQL dialects, CONCAT with NULL arguments treats NULL as an empty string, producing a non-NULL result. For example, CONCAT(NULL, 'a') or CONCAT(NULL, NULL) typically returns a non-null string (empty or partial result). Other functions like LENGTH, NULLIF, INSTR, TAN generally return NULL when any argument is NULL.

Multiple choice technology programming languages
  1. function_name() {command-list }

  2. function_name ( ) { }

  3. function name (command list ) {

  4. None

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

Shell functions are declared using the function_name() { command-list; } syntax. The function name is followed by empty parentheses, then a command list enclosed in braces. This is the standard POSIX-compliant function declaration format in bash and other Unix shells.

Multiple choice technology programming languages
  1. while,until

  2. until, while

  3. repeat, while

  4. None

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

while loops continue as long as the condition returns true (exit status 0). until loops continue until the condition becomes true, meaning they execute when the condition returns false (non-zero exit status). This is the inverse logic of while loops.