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
-
try {throw 3;} catch(int i){ rethrow; }
-
try {throw 3; rethrow ;} catch(int i){}
-
try {throw 3;} catch(int i){ rethrow 3; }
-
try {throw 3;} catch(int i){ throw; }
D
Correct answer
Explanation
In C++, the correct syntax to re-throw the currently caught exception is a standalone throw; statement within a catch block. Specifying throw 3; or rethrow creates a new exception or results in syntax errors, as rethrow is not a keyword. Thus, the option using throw; is the syntactically correct choice.
-
logical_error
-
runtime_error
-
domain_error
-
bad_exception
B
Correct answer
Explanation
range_error inherits from runtime_error because it detects problems during execution when values fall outside valid ranges. This is distinct from logical_error, which is for violations detectable before the program runs (like invalid arguments).
-
static_cast
-
reinterpret_cast
-
dynamic_cast
-
const_cast
B
Correct answer
Explanation
reinterpret_cast is used for casting inherently incompatible pointer types. It simply reinterprets the bit pattern without any type safety checks, making it the most dangerous but flexible casting option for unrelated types.
-
Input Iterator
-
Output Iterator
-
Forward Iterator
-
None of these
C
Correct answer
Explanation
Forward iterators must support dereferencing (*), equality comparison (==), assignment (=), and increment (++). Input iterators lack assignment capability, and output iterators cannot compare equality, making Forward Iterator the correct answer.
B
Correct answer
Explanation
Variable scope is typically confined to its context. Different files can have variables with the same name because they operate in different scopes (file scope, local scope, namespaces). The names only conflict if they're in the same scope or improperly shared across compilation units.
-
READ and WRITE
-
GET and PUT
-
Both a and b
-
None of the above
A
Correct answer
Explanation
Random access I/O operations allow reading or writing specific records directly by key or position. READ and WRITE statements provide this random access capability. GET and PUT are typically used for sequential I/O processing where records are accessed in order.
-
(a) When you want to invoke a map value (not a map value pair)
-
when you want to execute if else if constructs
-
when you want to invoke a when rule
-
when you want to invoke a decision tree
-
(a) They are stored on the clipboard as temporary variables
-
(b) They exist only within the context of an activity
-
(c) They can be stored in the database
-
(d) They are stored in a named page that is created automatically
B
Correct answer
Explanation
Local variables in Pega activities are scoped only to that activity's execution context. They are NOT stored on the clipboard page (A), cannot be stored in the database (C), and are NOT in automatically created named pages (D). They exist temporarily during activity execution only.
-
catch (float)
-
catch (...)
-
catch (int)
-
catch (long)
C
Correct answer
Explanation
Exception handlers are evaluated sequentially, and the first handler that matches the thrown exception type catches it. Since an int is thrown and catch(int) appears before catch(...), the int handler is selected. The catch(...) is a catch-all for any unmatched exception type.
-
first >> second >>
-
first >>
-
Compile time Error
-
Runtime Error -- ConcurrentModificationException
B
Correct answer
Explanation
The code outputs 'first >>' because the while loop uses iterator.hasNext() which becomes false after the first iteration (iterator.next() advances past the only element 'first'), causing the loop to terminate before 'second' can be printed. There is no compilation error and ConcurrentModificationException only occurs with structural modifications during iteration.
-
Internal Field Seperator
-
Internal File Seperator
-
Implicit Field Seperator
-
Implicit File Seperator
A
Correct answer
Explanation
IFS (Internal Field Separator) is a shell variable that determines how word splitting occurs after expansion. It specifies the characters used to delimit fields in commands - typically space, tab, and newline.
A
Correct answer
Explanation
The package statement, if present, must be the first non-comment statement in a Java source file. This rule ensures the package declaration appears before any imports or class declarations.
A
Correct answer
Explanation
To solve this question, the user needs to know the basic syntax and rules of defining a function in computer programming.
In Python, a catch (or a function) can have comma-separated multiple arguments. These arguments can be used to pass values or variables to the function to perform some operation.
Therefore, the correct answer is:
The Answer is: A) True