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
  1. bug

  2. debug

  3. cursor

  4. icon

  5. None of these

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

In computing terminology, an error or flaw in a program is commonly called a 'bug'. Debug is the process of finding and fixing bugs. Cursor is the on-screen indicator, and icon is a graphical symbol.

Multiple choice
  1. ensures that only the correct data type is entered into a field

  2. verifies that all required data is present

  3. determines whether a number is within a specified limit

  4. tests if the data in two or more associated fields is logical

  5. None of these

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

A range check validates that entered data falls within specified minimum and maximum boundaries. It's different from type checking (ensures correct data type), completeness check (ensures required fields are filled), or consistency check (ensures logical relationships between fields).

Multiple choice
  1. executed

  2. referenced

  3. imported

  4. declared

  5. None of these

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

In Java, packages must be imported using the import statement before they can be used in a program. This makes the classes and interfaces from the package available to your code. Packages don't need to be executed, referenced (too vague), or declared before use - they must be explicitly imported.

Multiple choice
  1. begin the line with a # sign

  2. begin the line with double slashes (/ /)

  3. begin and end the line with double hyphens (-_-)

  4. indent the line

  5. None of these

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

C++ uses double forward slashes (//) to indicate single-line comments. Everything after // on that line is treated as a comment and ignored by the compiler. Multi-line comments use /* */ syntax.

Multiple choice
  1. Define the attribute as required

  2. Define subtypes

  3. Define each attribute as having an initial value that is recognized as blank

  4. Define supertypes

  5. None of these

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

Supertypes are more general entity types that contain subtypes. Defining supertypes doesn't address null value ambiguities - null ambiguities are typically resolved by defining attributes as required, setting default/initial values, or using subtypes to categorize data more precisely.

Multiple choice
  1. 0

  2. 1

  3. -1

  4. None of the above

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

In C and C++, enumerated data types (enums) assign integer values starting from 0 by default. The first enumerator gets value 0, the next gets 1, and so on sequentially. However, programmers can explicitly assign different values if needed. This default behavior makes enums useful for array indexing and creating named constants.

Multiple choice
  1. Runtime error

  2. Compiler error

  3. Linker error

  4. Syntax error

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

The code has a typo: 'void mail()' instead of 'void main()'. This creates a linker error because the linker looks for the main() function as the program entry point but can't find it. The program compiles successfully but fails during linking. This is a common error that occurs when the required main() function is missing or misspelled, preventing the program from being properly linked into an executable.

Multiple choice
  1. True

  2. False

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

The arrow operator (->) is used in C/C++ to access members of a structure or class through a pointer. If ptr is a pointer to a structure, ptr->member is equivalent to (*ptr).member. This is a fundamental pointer operation for structured data.

Multiple choice
  1. Linker combines the object files into a single executable program.

  2. Linker converts the source file into object file.

  3. Linker converts the source file into executable file.

  4. None of the above

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

A linker combines multiple object files (compiled from source code) into a single executable program. It resolves references between modules and performs address binding. Compilers create object files, while linkers create the final executable.