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
-
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
-
p is a function that accepts an argument which is a pointer to a character array and returns an integer quantity
-
p is a pointer to a function that accepts an argument which is a pointer to a character and returns an integer quantity
-
None of the above
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].
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.
A
Correct answer
Explanation
An overloaded operator as a non-static member function of a class implicitly receives the this pointer as its first argument. Therefore, a unary operator requires no explicit arguments when overloaded as a member function.
B
Correct answer
Explanation
In C++, operator overloading allows you to redefine the behavior of an operator for user-defined types, but it cannot change the operator's precedence, associativity, or the number of operands.
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.
A
Correct answer
Explanation
In Documentum, you can create custom object types without explicitly specifying a supertype. The system will assign a default supertype if none is provided.
-
reinterpret_cast
-
static_cast
-
dynamic_cast
-
const_cast
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.
A
Correct answer
Explanation
In Documentum, custom object types can be created without specifying a super type, though they will typically default to inheriting from dm_sysobject. The statement reflects that creating a custom type doesn't strictly require explicitly defining a super type in the creation command.
-
COBOL-68
-
COBOL-74
-
COBOL-85
-
COBOL-9x
C
Correct answer
Explanation
COBOL-85 was the version where the GO TO statement was eliminated from the standards. Earlier versions (68, 74) still included GO TO, and COBOL-9x maintained this structured programming approach without GO TO.
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.
-
func( 9, 5.67 )
-
func( 4 )
-
func()
-
func( ,4 )
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.
-
Pointer
-
References
-
Both
-
None of the above
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.
-
RAISE
-
PRAGMA EXCEPTION_INIT
-
OTHERS
-
EXCEPTION
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.
-
A public class which contains a main method with proper signature (Arguments, return types etc).
-
We can run any classes
-
Only those classes which have public no argument constructors.
-
None of these
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.