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 php
  1. Ends execution of the current switch structure

  2. Moves on to the next iteration of the current for, foreach, while, do-while or switch structure

  3. Ends execution of the current for, foreach, while, do-while or switch structure

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

The break statement is used to immediately terminate the execution of the current loop (for, foreach, while, do-while) or switch structure. Option 4424 is too narrow as it only mentions switch, and 4425 describes the continue statement, which skips to the next iteration rather than ending the structure.

Multiple choice .net vb
  1. One

  2. Two

  3. Three

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

.NET Framework has two compilation levels: first, source code compiles to Intermediate Language (IL) by language compilers (C#/VB.NET); second, IL compiles to native machine code by the Just-In-Time (JIT) compiler at runtime.

Multiple choice .net vb
  1. Specifies that any variable name is declared (with type) before use

  2. Specifies whether strings should be compared as binary

  3. Specifies that variables should be initialized before use

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

Option Explicit On requires that all variables be declared before use. This prevents undeclared variables (often from typos) from being created implicitly, catching naming errors at compile time rather than runtime.

Multiple choice .net vb
  1. Exit

  2. Close Sub

  3. Exit Sub

  4. Kill

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

To terminate code execution within a VB.NET method, you can use the "Exit Sub" statement.

Explanation of options:

A. Exit: The "Exit" keyword is used to exit a loop or block of code, but it cannot be used to terminate a method. It is not the correct option in this scenario.

B. Close Sub: This is not a valid statement in VB.NET. It is not the correct option.

C. Exit Sub: The "Exit Sub" statement is used to immediately exit from a subroutine (method) in VB.NET. It allows you to terminate the execution of the method and return control to the calling code. This is the correct option.

D. Kill: The "Kill" statement is used to delete a file in VB.NET and is not related to terminating code execution within a method. It is not the correct option.

Therefore, the correct answer is: C. Exit Sub

Multiple choice .net vb
  1. Using Only Get..EndGet with in property definition

  2. Using Only Set..EndSet with in property definition

  3. Using both Get and Set

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

In VB.NET, a read-only property is created by including only the Get accessor without a Set accessor. This allows the property value to be read but not modified from outside the class. Option B (only Set) would create a write-only property, while option C (both Get and Set) creates a read-write property.

Multiple choice java
  1. Vptr

  2. Void

  3. Null

  4. Zero

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

A null pointer is a special pointer value that points to no memory location and is typically represented as zero. Void pointers can point to any data type but are not necessarily null. The question describes a null pointer, which can be assigned to any pointer type and conventionally has the value zero.

Multiple choice java
  1. Virtual functions

  2. Inline functions

  3. Static functions

  4. Friend functions

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

Inline functions are expanded at compile time - the function call is replaced by the actual function code, eliminating function call overhead. This is a compiler optimization that trades code size for execution speed. Virtual functions use dynamic dispatch, static functions have file scope, and friend functions access private data - none of these replace the call with code at compile time.

Multiple choice typrun
  1. TYPRUN= HOLD

  2. TYPRUN= SCAN

  3. TYPRUN= SUB

  4. TYPRUN= HELD

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

TYPRUN=SCAN is used to check JCL for syntax and logic errors without executing the job. HOLD places the job in held status, SUB is not a valid parameter, and HELD is not the correct parameter name.

Multiple choice qn6
  1. Converting reference type to value type

  2. Converting value type to reference type

  3. converting int to string

  4. none

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

Boxing converts a value type (like int, float) to a reference type (object) by wrapping it in an object. This allows value types to be treated as objects when needed. The reverse process is unboxing.

Multiple choice qn7
  1. Converting reference type to value type

  2. Converting valuetype to reference type

  3. Converting int to string

  4. None

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

Unboxing extracts the value type from a reference type (object) that was previously boxed. It is the explicit conversion from object back to the original value type. Boxing/unboxing have performance implications.

Multiple choice qn8
  1. Input

  2. Return

  3. Output

  4. Extern

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

Output parameters are used in stored procedures to return values to the calling program. Input parameters pass data in, Return is for status codes, and Extern is not a parameter direction.

Multiple choice qn9
  1. String

  2. Int

  3. bool

  4. Object

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

The ExecuteScalar method of a command object returns a single value from the first row of the result set returned by the query. The data type of the returned value depends on the type of the column being retrieved.

In this case, the options provided are:

A. String: This option is incorrect because the ExecuteScalar method does not always return a string. It can return values of different data types, depending on the column being retrieved.

B. Int: This option is incorrect because, similar to option A, the ExecuteScalar method does not always return an integer. It can return values of different data types.

C. bool: This option is incorrect for the same reasons mentioned above. The ExecuteScalar method can return values of different data types, not just boolean values.

D. Object: This option is correct. The ExecuteScalar method returns the value as an Object data type. This allows for flexibility in handling different data types returned by the query.

Therefore, the correct answer is D.

Multiple choice c sharp
  1. Freeing memory on the stack.

  2. Avoiding memory leaks.

  3. Freeing memory occupied by unreferenced objects.

  4. Closing unclosed database collections.

  5. Closing unclosed files.

Reveal answer Fill a bubble to check yourself
A,D,E Correct answer
Explanation

Garbage Collector automatically manages heap memory by reclaiming objects that are no longer referenced, but it has specific limitations. It does NOT free stack memory (stack is automatically managed as methods return), does NOT close database connections (requires explicit closure or connection pooling), and does NOT close file handles (requires explicit closing). Option B is incorrect because GC cannot prevent all memory leaks - leaks can still occur with unintended references. Option C is something GC DOES perform (freeing unreferenced objects).

Multiple choice c sharp
  1. It is allocated at compile time

  2. Declaration and initialization is separated

  3. It is allocated at runtime

  4. all of these

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

Read-only variables (const, readonly) are allocated at runtime in .NET, unlike compile-time constants. Option A is incorrect because compile-time allocation is for constants (const), not readonly fields. Option B is incorrect - readonly variables can be declared and initialized separately (declaration at field, initialization in constructor). Option D is false since the other options contradict each other and cannot all be true.