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. p is a function that accepts an argument which is a pointer to a character and returns a pointer to a 10 element integer array

  2. p is a function that accepts an argument which is a pointer to a character array and returns an integer quantity

  3. p is a pointer to a function that accepts an argument which is a pointer to a character and returns an integer quantity

  4. None of the above

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

The declaration int (p(char *a))[10] is complex: p is a function taking char and returning a pointer to an array of 10 ints. The syntax (p(char *a))[10] means p is a function (not a pointer), and it returns a pointer to [10]. Option B incorrectly says it returns an int. Option C describes a pointer-to-function, which would be written as int (*p)(char) without the [10].

Multiple choice technology programming languages
  1. True

  2. False

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

Function overloading in C++ requires differences in the parameter list (type, number, or order). Return type alone cannot distinguish overloaded functions because the compiler cannot determine which version to call based solely on the return type, especially in expressions where the return value might be discarded.

Multiple choice technology programming languages
  1. True

  2. False

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

References in C++ must be initialized upon declaration and cannot be reseated (assigned to refer to a different object). Since arrays require elements that can be default-constructed and reassigned, arrays of references are prohibited by the language specification.

Multiple choice technology programming languages
  1. reinterpret_cast

  2. static_cast

  3. dynamic_cast

  4. const_cast

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

reinterpret_cast is used for low-level reinterpreting of bit patterns between inherently incompatible pointer types (e.g., int* to char*). static_cast is for related types, dynamic_cast for polymorphic downcasting, and const_cast for removing const/volatile.

Multiple choice technology programming languages
  1. True

  2. False

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

In C++, a function prototype is only required if the function is called before it is defined in the file. If the complete function definition appears before the first function call, the definition itself serves as the declaration. The compiler can determine the function's signature from its definition.

Multiple choice technology programming languages
  1. func( 9, 5.67 )

  2. func( 4 )

  3. func()

  4. func( ,4 )

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

In C++, when calling a function with default parameters, you cannot skip an earlier parameter while providing a value for a later parameter. If you want to specify the second parameter, you must also provide a value for the first parameter. The syntax 'func(,4)' is invalid because it omits the first argument.

Multiple choice technology programming languages
  1. True

  2. False

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

A const pointer (pointer to const data) cannot be implicitly assigned to an ordinary (non-const) pointer because this would allow modification of data that was declared as constant. This would violate the const-correctness principle of C++. You would need an explicit const_cast to perform this conversion, and even then, modifying the data through the resulting pointer is undefined behavior.

Multiple choice technology programming languages
  1. RAISE

  2. PRAGMA EXCEPTION_INIT

  3. OTHERS

  4. EXCEPTION

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

In PL/SQL, user-defined exceptions are raised using the RAISE statement. The EXCEPTION keyword is used in the exception declaration section (EXCEPTION_INIT pragma links error codes to exceptions) and in the exception handling block (BEGIN...EXCEPTION...END). To actually raise a user-defined exception, you must declare it, then use RAISE exception_name.

Multiple choice technology platforms and products
  1. A public class which contains a main method with proper signature (Arguments, return types etc).

  2. We can run any classes

  3. Only those classes which have public no argument constructors.

  4. None of these

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

To run a Java class directly from the Package Explorer, the class must contain a standard main method with the correct signature (public static void main(String[] args)). Other classes without this entry point cannot be executed directly as standalone applications.