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. Encapuslation

  2. Abstraction

  3. Information Hiding

  4. Polymorphism

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

Abstraction focuses on exposing only essential features while hiding implementation details. It's about showing what an object does rather than how it does it. Encapsulation is about bundling data and methods together, while information hiding is a related concept about restricting access to internal details.

Multiple choice technology programming languages
  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 compiler replaces the function call with the actual function code, eliminating the overhead of function call mechanism. Virtual functions use dynamic binding, static functions have class scope, and friend functions are non-member functions with special access rights.

Multiple choice technology programming languages
  1. Automatic

  2. Global

  3. Static

  4. External

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

Storage classes in C are auto (default for local variables, stored on stack), static (retains value between calls, stored in data segment), extern (variables defined in another file), and register (stored in CPU registers). 'Global' is not a storage class - global variables use extern or static storage classes.

Multiple choice technology programming languages
  1. Void

  2. Int

  3. Bool

  4. none of the above

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

In C++, if no return type is specified for a function, the default return type is 'int'. This is a legacy feature from C. However, it's considered poor practice - always explicitly specify the return type. The 'void' return type means the function returns nothing, while 'bool' is for boolean return values.

Multiple choice technology programming languages
  1. Reference types are stored on stack and value types are stored on heap area.

  2. Boxing allows you to convert value types to reference types.

  3. For boxing, during runtime it creates a temporary reference type box for the object on the heap

  4. Unboxing allows you to convert reference type to value type

Reveal answer Fill a bubble to check yourself
B,C,D Correct answer
Explanation

In C#, boxing converts value types to reference types, and unboxing reverses this. During boxing, the runtime creates a temporary reference type object on the heap to hold the value type. Reference types are stored on the heap, not the stack (option A is wrong), and identifiers can contain numeric characters (option D is wrong).

Multiple choice technology programming languages
  1. In C#, we can define one and only one main( ) method .

  2. If there is more than one main( ) method defined in your programme ,the compiler will return compile time error.

  3. If there is more than one main( ) method defined you can explicitely tell the compiler which main( ) method is to be used as the entry point.

  4. All the statements are wrong

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

C# allows multiple Main() methods in different classes, but you must specify which one is the entry point using compiler options. The compiler returns an error if multiple Main() methods exist without an explicit entry point specification. Option A is wrong because you CAN define multiple Main() methods.

Multiple choice technology programming languages
  1. These are the names that one user gives to variables such as the user defined types(eg;classes and structs)

  2. These are not case sensitive.

  3. Their names must begin with a letter or with a underscore .

  4. They must not contain any numeric characters

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

C# identifiers are names for variables, classes, structs, etc. They must begin with a letter or underscore, are case-sensitive (option B is wrong), and can contain numeric characters after the first character (option D is wrong).

Multiple choice technology mainframe
  1. For loop

  2. Do-while loop

  3. method

  4. None of the above

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

COBOL's PERFORM...UNTIL executes the loop body first, then checks the condition - similar to do-while in Java/C++ (condition checked at bottom, guaranteed at least one iteration). PERFORM...VARYING is more like a for loop.

Multiple choice technology mainframe
  1. Use a standard perform statement

  2. Use an in line perform

  3. Skillful use of the COBOL reserved word "AFTER"

  4. This is not possible in COBOL

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

The PERFORM statement with the AFTER clause in COBOL creates a loop that executes the body first, then checks the condition for subsequent iterations. This is equivalent to a do-while loop in other languages.

Multiple choice technology mainframe
  1. Gives control to the verb following the next period & gives control to the next verb after the explicit scope terminator.

  2. Gives control to the next verb after the explicit scope terminator & gives control to the verb following the next period.

  3. Both are same.

  4. Control goes to the next paragraph & control goes to next section

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

NEXT SENTENCE transfers control to the statement immediately after the next period (sentence terminator), while CONTINUE transfers control to the statement after the explicit scope terminator (like END-IF or END-PERFORM). They are not equivalent.

Multiple choice technology mainframe
  1. Bad coding. The loop will not be executed.

  2. 5 times.

  3. 10 times.

  4. 15 times.

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

WS-N starts at 0, gets set to 5, then PERFORM B-PARA WS-N TIMES executes B-PARA exactly 5 times. The fact that B-PARA changes WS-N to 10 doesn't affect the loop count - PERFORM TIMES evaluates the count once at the start.