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 .net
  1. It prevents a procedure from being self contained.

  2. It makes it easier to document the code.

  3. Local variable names can be reused in other procedures.

  4. Both a and b.

  5. All of the above.

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

Module variables break encapsulation by making procedures dependent on external state rather than being self-contained units. This complicates documentation since the variable's usage spans multiple procedures, and it prevents local variable name reuse within individual procedures. All three are valid reasons to avoid module-level variables.

Multiple choice .net
  1. the length of the variable.

  2. the name of the variable.

  3. the accessibility of the variable.

  4. the datatype of the variable.

  5. the lifetime of the variable.

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

To answer this question, the user needs to have knowledge of programming concepts, specifically the concept of variable scope.

The scope of a variable refers to the accessibility or visibility of the variable within a program. It determines where and how the variable can be accessed and used.

Now, let's go through each option and explain why it is right or wrong:

A. the length of the variable: This option is incorrect. The scope of a variable is not related to its length. The length of a variable may refer to the number of characters or bytes used to store its value, but that is not the same as its scope.

B. the name of the variable: This option is incorrect. The scope of a variable is not determined by its name. While the name of a variable is important for identifying and referencing it, it does not define its scope.

C. the accessibility of the variable: This option is correct. The scope of a variable refers to its accessibility within a program. It determines where and how the variable can be accessed and used. The accessibility of a variable can be influenced by factors such as its declaration location and the programming language being used.

D. the datatype of the variable: This option is incorrect. The scope of a variable is not related to its data type. The data type of a variable determines the type of values it can store, but it does not define its scope.

E. the lifetime of the variable: This option is incorrect. The scope of a variable and its lifetime are related concepts but not the same. The lifetime of a variable refers to the period during which the variable exists in memory, whereas the scope refers to where and how the variable can be accessed within a program.

The Answer is: C. the accessibility of the variable.

Multiple choice .net
  1. Array name

  2. Index value of the element

  3. Element value

  4. Both a and b.

  5. All of the above.

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

To reference an element in an array, you need to know the array name and the index value of the element.

Option A: Array name. This option is partially correct. The array name is required to identify the specific array you want to access.

Option B: Index value of the element. This option is correct. The index value is used to specify the position of the element within the array. It represents the location of the element in the array.

Option C: Element value. This option is incorrect. The element value is the actual value stored in the array at a specific index, but it is not required to reference an element in an array.

Option D: Both A and B. This option is correct. To reference an element in an array, you need both the array name and the index value of the element.

Option E: All of the above. This option is incorrect. Option C (Element value) is not required to reference an element in an array.

Therefore, the answer is D. Both A and B.

Multiple choice .net
  1. 1

  2. 2

  3. 3

  4. Any number of variables can be declared in an array.

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

To solve this question, the user needs to know about variables and data structures.

A variable is a named storage location in a computer's memory that holds a value. In programming, variables are used to store and manipulate data.

A structured data type is a data type that groups together related values. Examples of structured data types include arrays, structs, and classes.

Now let's go through each option and explain why it is right or wrong:

A. 1: This option is incorrect. Variables are not limited to just one in a structured data type. Structured data types allow for the grouping of multiple variables together.

B. 2: This option is incorrect. Structured data types can have more than two variables. The number of variables allowed in a structured data type is not limited to any specific number.

C. 3: This option is incorrect for the same reason as option B. The number of variables allowed in a structured data type can be more than three.

D. Any number of variables can be declared in an array: This option is partially correct. Arrays are a type of structured data type that allows for the declaration of any number of variables. Arrays can hold multiple values of the same data type.

Therefore, the correct answer is:

D. Any number of variables can be declared in an array.

Multiple choice .net
  1. associate.

  2. constituent.

  3. element.

  4. member.

  5. part.

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

To answer this question, the user needs to know about structures in programming. A structure is a user-defined data type that groups related data of different data types. Structures in programming consist of variables or data members.

Each option will now be explained:

A. associate: This option is incorrect. An "associate" usually refers to a person or entity that is connected with another in some way. It does not accurately describe a variable inside a structure.

B. constituent: This option is incorrect. A "constituent" refers to a part or component of something that is considered as a whole. It is not the correct term for a variable inside a structure.

C. element: This option is incorrect. An "element" is a basic, indivisible unit of a larger system. It is not the correct term for a variable inside a structure.

D. member: This option is correct. A "member" is the correct term for a variable inside a structure. It is a data member or field that is part of the structure.

E. part: This option is incorrect. "Part" is a general term that refers to any piece or component of a whole. It is not the correct term for a variable inside a structure.

Therefore, the correct answer is:

The Answer is: D. member.

Multiple choice .net
  1. TextBoxes

  2. Labels

  3. Structures

  4. Controls

  5. An array can hold all of the above.

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

To answer this question, we need to understand the concept of arrays and datatypes in programming.

An array is a data structure that can hold a fixed number of elements of the same datatype. Each element in the array is accessed by its index.

Now let's go through each option and determine if an array can hold that datatype:

A. TextBoxes: This option refers to a graphical user interface element used for user input. In programming, TextBoxes are usually represented by objects or classes. Therefore, an array can hold TextBox objects.

B. Labels: Similar to TextBoxes, Labels are another graphical user interface element used for displaying text. Labels are also represented by objects or classes, so an array can hold Label objects.

C. Structures: A structure is a user-defined data type that can hold different types of data under a single name. An array can hold structures, as long as all the elements in the array have the same structure type.

D. Controls: Controls refer to various graphical user interface elements, such as TextBoxes, Labels, Buttons, etc. Since we have already established that arrays can hold TextBoxes and Labels (which are types of controls), an array can hold Controls.

E. An array can hold all of the above: This option is correct. Arrays can hold TextBoxes, Labels, Structures, Controls, and any other data type as long as all the elements in the array have the same datatype.

Therefore, the correct answer is E. An array can hold all of the above.

Multiple choice .net
  1. Application.VariableName = Value

  2. Application.VariableName = (Value)

  3. Application(VariableName) = Value

  4. Application(VariableName) = (Value)

  5. Application("VariableName") = Value

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

Application variables in ASP.NET are accessed using the Application collection with string keys in parentheses. The syntax Application("VariableName") = Value is correct. The variable name must be a string, not an identifier.

Multiple choice .net
  1. an event.

  2. a function.

  3. a variable.

  4. Both a and b.

  5. All of the above.

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

A Get procedure returns a value when a property is accessed, which is the defining behavior of a function. Events are triggered by actions, variables store data, and a property's Get specifically returns a computed or stored value.

Multiple choice java
  1. True

  2. False

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

In languages like C# and Java, primitive types (value types) such as int, char, and bool are typically allocated on the stack for performance. Objects (reference types) are allocated on the heap, while their references are stored on the stack.

Multiple choice java
  1. True

  2. False

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

To evaluate this statement, we need to understand the behavior of the default statement in a switch statement.

The default statement in a switch statement is optional and serves as a catch-all case. It is executed if none of the other cases match the value being switched.

Now let's go through each option:

A. True: This option is incorrect. The default statement is only executed if none of the other cases match the value being switched. If any of the other cases match, the default statement is skipped.

B. False: This option is correct. The default statement is not always executed. It is only executed if none of the other cases match the value being switched.

Therefore, the correct answer is B. False.

Let me know if you have any further questions!

Multiple choice asp
  1. Break it up into smaller easier-to-manage files that can serve as subroutines and function calls.

  2. Keep it nice and simple in one file and use subroutines and function calls.

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

Breaking code into smaller, modular files improves maintainability, reusability, and debugging. You can create libraries of frequently used functions and subroutines, then include them only where needed. Keeping everything in one file (option B) creates maintenance nightmares as the application grows and makes code reuse difficult.

Multiple choice asp
  1. <% Language=VBScript %>

  2. <% ASPLanguage = VBScript %>

  3. <%@ Language=VBScript %>

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

ASP language directives use the @ symbol: <%@ Language=VBScript %>. This is a special directive syntax that must be placed at the very beginning of an ASP file to specify which scripting language to use. The @ symbol distinguishes it from regular ASP code delimiters. While VBScript is the default, explicitly declaring it is good practice, especially when using JavaScript instead.

Multiple choice .net asp
  1. <% '#include virtual="banner.asp" %>

  2. <!-- #include virtual="banner.asp" -->

  3. <-- #include virtual="banner.asp" -->

  4. <-- #include virtual="banner.asp" -->

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

The correct format for an include statement in ASP/SSI uses HTML comment syntax with the #include directive. Option B shows the proper format: . The virtual attribute specifies a virtual path relative to the web root. Option A uses incorrect ASP-style delimiters, while options C and D are missing the exclamation mark after the opening bracket.

Multiple choice .net asp
  1. At the beginning to keep the code neat and tidy.

  2. Anywhere in the code where it is actually needed.

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

Include files containing functions, subroutines, and configuration code should be placed at the beginning of your page. This makes the code more maintainable and ensures these definitions are available before any code that might need them. Placing configuration includes at the top is a best practice in ASP development for code organization and readability.