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
  1. C++ provides declaring an alias name for a given namespace.

  2. Namespace can be declared without any name or even unnamed.

  3. Namespace defination can be extended over multiple files.

  4. Instance variable can be created for a namespace.

  5. Namespace defination should not be terminated by a semicolon.

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

 We cant create instance variable's for namespace. There are not similar to classes in C++.

This option is false statement. Hence this option is the correct choice to be choosen as a false statement.

Multiple choice
  1. All functions declared inside a class are inline functions by default.

  2. Inline functions can be declared outside a class by using inline keyword.

  3. Any modifications in an inline function needs recompilation of the program to use modified functionality.

  4. Declarartion of a function which is inside a class with inline keyword leads to compile time error.

  5. By declaring small functions (with less computation time) as inline function, performance of the program is increased.

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

This statement is false. We know if we declare a function inside a class, it is implicitly inline function. Eventhough we explicitly write inline keyword for a function inside a class, compiler does the same. It doesnt raise compile time error. Hence, this is a false statement & correct option to choose according to the question. 

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 a numeric input falls within a predefined acceptable range (minimum and maximum values). Unlike type checks (data type validation), presence checks (required fields), or consistency checks (cross-field logic), range checks specifically verify that a number is within specified bounds - for example, ensuring age is between 0 and 120 or percentage between 0 and 100.

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 before they can be used in a program. The import statement makes classes and interfaces from other packages available to the current code, allowing organized code reuse across different packages.

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

In modern C++ (and C99+), single-line comments begin with double slashes (//). This syntax tells the compiler to ignore everything from // to the end of that line. Option B shows this correctly (with a space, but the description is accurate).

Multiple choice
  1. ?:

  2. =

  3. -

  4. ++

  5. No such operator exists

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

Following are the operators which cannot be overloaded: Conditional/ ternary operator (?: ), Class member access operator ( . , -> ), Scope resolution operator ( :: ) and Size operator ( sizeof ).

Multiple choice
  1. Class defined in iostream.h header file.

  2. Object of the istream class.

  3. Package having different class definition.

  4. Function which is already defined.

  5. None of the above

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

cin is the predefined object of the istream class and is used for performing the standard input operations.

Multiple choice
  1. Declaration : friend void operator –(space &s); Definition :void operator –(space &s){ s.x=-s.x; s.y=-s.y;}

  2. Declaration : friend void operator –(); Definition : void space operator –(){ x=-x; y=-y;}

  3. Declaration : friend void operator –(space &s); Definition : void operator –(space &s){ x=-x; y=-y;}

  4. Unary minus operator cannot be overloaded using friend function

  5. None of the above

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

There is no need to use scope resolution operator if function is defined as friend. We have to pass the arguments by reference.